First running version, still some problems because my version takes more iterations than original. There may be a problem in the Hessian because I'm passing all of it rather than the lower triangular part only. To be investigated.