Added Pauls code for sanitizing the document contents.