Continue major refactoring. Decouple all parsing logic from main class. Add unit tests.