Ported some threads to pthreads.