Fix bugs with build on Windows