Fix memory leaks
Merge pull request #1290 from sjinks/1.2.4

[1.2.4] Fix memory leaks