Fix for memory leaks.