Replaced some global variables, introducing RouteTracker and subclass.