fixed reuse of md5 hash, fix output of randomness