Refactored to make better use of lenses.