Rewriting clauses to support multiple modes