Only flatten packages and not static fields.
Replace underscores to prevent collisions in flat paths.