Fix a memory management issue