Add guards to the complete document retireval process

Helps fix #147