couple of fixes to derivative calculation