Large refactoring of rules