Fix for various issues found when testing on windows.