move back flattenTerms before AddTopCellConfig