Multiple bugfixes on Windows