Refactored Rules to BiRewrite code.