Fixed the derivative part, after the unit-tests failed.