Cleanup of router code