Fix referential integrity problems updating internal documents