Bugfix: fix a possible infinite loop in RandomStrategy.