Patch provided by Gabor Lencse for generating better randomized mesg IDs.