Bugfixes for Windows build