Fix for potential nil values in a table

table.Shuffle assumed all values existed, now it makes sure it uses an
array with no holes in it and will restructure the input table if it
does.