Fix initialization of threads