Major refactor.