Added protection for empty documents.