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

added some memory cleanup code and memory debugging code
merged master into resources