Fixed a bug in jacobian calculation.