Add flag to link with pthreads.
Remove unneeded c casts.