Fix some bugs on GetNRandom.