Optimized the code.

There was no need to shuffle the whole list of keys if only the first
N=num_want were being used.