Added check for undefined version field in the document metadata when updating.