Backpatch certain files through 9.1
Uriy Zhuravlev and Alexander Korotkov, reviewed by Jeff Janes, some cleanup by me.