Implements the various pieces of the routing functionality.