My upstreamable changes so far

I put them all in one pull request, assuming you are fine with either all of them, or don’t mind cherry-picking those that you like.

Enjoy!