Improve the handling of deriving, in error cases