Fixed some memory issues in MG solver.