Holy poop a big refactoring