Save the document whenever it is updated/reloaded.  Fix a couple of issues
exposed by this change.