Massive refactoring