see 2c60bf77f9e7b9ab5a0143af5564f463a41a257c, from the "later" branch. should port this over to `cpp-rewrite` branch, as it's probably the right thing to do.