Fix and improve multiple places about random number generation and
shuffling
Merge pull request #848 from netheril96/random

Fix and improve multiple places about random number generation and shuffling
Merge remote-tracking branch 'upstream/dev' into test