Refactored to use modes.