Fixed a typo and introduced shared random everywhere.