Refactored out the basis function derivatives.