Minor refactoring and clean up.