change rand() to drand48_r

(I have tried also random_r but got segfaults on exit) (?)