Big refactor.