Assorted fixes for bugs when testing on Windows