HUGE refactor.