move flattenTerms before AddTopCellConfig java backend