Instead of using rand(), which does suck horribly, just use this:
s1=((s1&4294967294)<<12)^(((s1<<13)^s1)>>19);
s2=((s2&4294967288)<<4)^(((s2<<2)^s2)>>25);
s3=((s3&4294967280)<<17)^(((s3<<3)^s3)>>11);
return s1^s2^s3;
Tausworthe random number generator, generates quality 32-bit random integers with a cycle of something like 2^88, extremely fast and simple. Seeding is left as an excercise to the reader, I just set s1, s2 and s3 to the seed times various large integers.