More memory fixes/tests