Resource leak fixes
Merge pull request #13 from Alicemargatroid/master

Resource leak fixes