Optimize the queues.