various fixes in rand module