Windows: fix #2117, fix #2139, fix #2080, fix #2263, fix #2256