Some refactoring and renaming.