Some minimal refactoring.