undo doc freeing change: crashes when doc has already been used elsewhere