Fixed problem with wrong empty queue condition.