Some refactoring.

Move the max range logic into the range view.
Put the gesture detection in a separate class.