Minor cleanup and refactoring.