fix some memory leaks.
sync for thread safety
more memory leaks
increment reference count as per clang
memory leak fix
more memory leak fixes.
Merge pull request #57 from tsaizhenling/master

memory leaks