Add new options and clean up code

New options about the usage of analytic Jacobian, the factor and diag
parameters of the MINPACK lmder function has been added. And code for
setting the options up has been move out from the main loop.