All this logic should be in `rand` itself.