improve generation of nested rules and their string representations.