Numerous windows fixes

Do not pull the whole thing, cherry-pick 55ac1fd3bc8fcc62fc5a0146c4cb1e751f16df4c.

We can worry about merging the rest in when I'm back.