Tag routing improvements. Fixes #5105.