Restructure names and namespaces for query models.