Reorganized the router functions and tweaked stuff for the next stage.