Another round of major refactoring.