Fixed bug in calc_jacobian()