Queue optimization