fixed problems with finding and deleting documents.