refactor: major refactoring and splitting into smaller more manageble modules/files + some bug fixes

Closes #15