Bigger refactoring of the routing component. Involves API changes and probably needs a bit cleanup.