Another round of clean-up and refactoring.