Lots of refactoring and renaming.