First batch of win32 fixes