Fix some issues with windows threads