move flattenTerms before streamCell