Bugfixes for analytic derivatives