Bugfixes.

Signed-off-by: deepak <dpak.cherian@gmail.com>
Added derivative calculation code.

Signed-off-by: deepak <dpak.cherian@gmail.com>