Memory management fixes.