Bug fixes related to the document server

These are some small changes need to fix various bugs reported in relation to the document server changes that have happened.