Fixing memory leaks.