All of the chunks within `ifs` look like good candidates for breaking into small methods to handle each, e.g. `process_remove_clauses`, `process_copy_clauses`, `generate_clauses`, etc.