Thread fixes for WinCE