Rework .rand to be a lot simpler, as well as fix a possible crash.