Win32 fixes

Mostly file handling stuff.