Bugfixes for Windows compatibility