Added some safeguards on documents