Router completely rewritten, with unit test coverage.