Bug: When a sub-document object is changed and then the main object is
removed, the removed object would re-appear, since the sub-document object
was still registered as changed and caused a write undoing the removal. The
issue was fixed by removing all registered sub-document objects as well from
the list during removal.