another massive refactoring