bug fix
fix some memory leaks and a new bug
Merge pull request #12 from lei-april/master

fix some memory leaks