fix some leaks
Merge pull request #18 from zaki50/fix-leaks

fix some memory leaks in native code