move flattenTerm before ResolveSyntaxPredicates