Refactored into smaller classes.