Fixing memory management.