Improve path hanlding in router.