Added ability to have more than 2 chains. Refactored jacobian_generator