Another round of refactoring