Refactor code, bump version to 0.9