Refactored out some more duplication.