Refactoring and clean-up.