Small fixes.
Split main module.
Finish refactor and add tests.
Add readme.