Refactor rule firing logic to be reusable in distributed systems.