changed lbfgsnomessages to remember the previous m gradients