Fix to check if doc.body exists before using it

This is the fix for issue 487. This only appears to be a problem for the 1.3x branch.