Fixed segmentation fault

fixed segmentation fault when the document queue is empty
Removed unnecessary printfs