Fix crash in restoreLinks