More optimizaitons

drain queue can deoptimize if the index of the queue is out of bounds