Replaced all srand and rand calls by qsrand and grand.