Fixed a dumb bug and also the random functions.