Halfway commit for a refactor.
Final refactor commit for today. This revision should be considered unstable.