put flattenTerms before AddTopCellRules