Fixed memory issues in randomized queue.