The rand is reinitialised when it can just use the outer one.
Merge remote-tracking branch 'fluffyfreak/rand_shadowing_fix'