Internal rewrite of rules