fix add_link mutation; add deadlock detection