Fix random data generation, remove an unneeded function