Fix memory leaks
Merge pull request #12 from DanWin/master

Fix memory leaks