Changed method for calculating Jacobian.