More work, including some refactoring and renaming.