Cherry picks

The two first fixes are really the essential ones for 3.5.x.

The remaining commits are refactoring preparation needed for documentation that I had not intended to be included in 3.5.x. However, it was pointed out that making non-fix changes to master is still too early to prevent divergence in later cherry picks. I have now halted all non-fix work in master until the release.

There is a corresponding request for nova.