Remove a few potential memory leaks
Merge pull request #369 from yuklai/master_leaks

Remove a few potential memory leaks