Merge 2.10.x into master

Another attempt at merging 2.10.x.

Recent merge of #2746 made this PR a little bit more difficult so I split the merge into two commits. The first commit resolves merge conflicts the same way as #2781 except for tests failures.

Hopefully this time all tests will pass.

Review by @retronym.