removing all calls to gen_thread. using pthreads instead.