Minor improvements for threads on Windows