Fix empty queue crash, fixes #612