Fix `rewriteLeaf`.

See #375.