More refactoring and simplification.