This restores 47459455, which was reverted in commit 452a14ef, along with fixes for a couple of bot failures.