Lots of refactoring in preparation for mutation constraints.