Fix flatten final ordering (was inverted)