move back flattenTerms before ResolveRewrite