better handle deleted docs in case pillow

http://manage.dimagi.com/default.asp?150498