HUGE internal refactor