WIP. First bit of refactor.