A bit of refactoring to clean up things.