Split routes into namespaces and factor common parts