make flattenTerms become two part, one before resolveSyntaxPredicate, one before FlattenSyntax