Another attempt to merge Windows fixes from jtanx