Flatten and simplify module structure.