Refactoring of rules parsing