Massive refactor