move FlattenTerms before ResolveSyntaxPredicates