added some memory cleanup code and memory debugging code
Merge pull request #28 from 5-second-rule/memory-management

added some memory cleanup code and memory debugging code