Refactored code, added function/Jacobian counts