move FlattenTerms before ResolveSyntaxPredicates

@traiansf please review