More memory reductions and cleanups