Fix thread setup issue