don't leak memory
Merge pull request #3626 from monsta/fixes

Fix some leaks