More memory management fixes.