Extract flattening of namespace code to module.