Fix bugs to get it run on Windows