Router enhancements

Since #189 cannot be merged yet, this is a cherry-pick of router enhancements.