Cleaning up and fixing router internals.