Refactor and fix memory leaks
Bump version 2.0