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

Resource leak fixes