Fixed threading issues on Windows machine.