Fix global leaks
Merge pull request #245 from syrnick/master

Fix global leaks