Fixed bug in differentiation.