Fix memory management
Merge pull request #1 from griffin-stewie/MemoryManagement

Fix memory management