Bug fixes for random sampler

Change-Id: I59edaad0e1115d242639a1a708ddd19f16eef647