Fix various bugs.
Fix jacobian computation.