Merge pull request #6 from crumblingstatue/master

Fix memory errors