Fixed bug in derivative.