Improve memory management during solve.