fixed nasty bug in netwon raphson, and improved speed for geo_p optimisation