Revert changes that were merged to master.

Reverted: 2e099caceb9..21102938e8ccb

I'm going to reapply some of them soon, but it's easier to revert them
all first, as there are conflicts. Also the number of changes that were
inserted since then, mean that there would be a huge gap between related
changes.