Correct the use of pthread_create() in several places.