At commit 90c8d87fe8701d2335671eb01cbc1d70f655c87f. I'm splitting this out because it's large and more generally useful.