Fix some bugs found on windows.