Lots more refactoring with the imperative logic divide.