Bug fix:cleanup in multi-thread
The cleanup is done in main thread
Merge pull request #18 from eminom/master

Merge pull request to fix cleanup issue.