Better dequeue and  bug in retry_job