First cut on rename refactoring

And some refactoring.