reduced the risk of memory leaks
small addition
Merge pull request #52 from frozeman/master

memory leak fixes