Refactoring main class, easier to unit test.
WIP testing.