move flattenTerms before FlattenSyntax (back)