fixed memory leaks.
Merge pull request #6 from hiralin/master

Fixed memory leaks