improved flattening.
3 files changed