Massive refactoring into seperate modules