refactor router haschange event triggering and listeners, remove some silly global state vars, etc.