Huge refactor.