Refactoring, fix memory leak. v2.0.0.