Minor refactoring and reorganizing.