Categorisation refactor optimizer for rule_checking