introduction of routing code

untested, but it's in here now!