Most of the way through refactor.