Refactors rules.