Untangle a lot of the logic and separate state management from URL matching