This commit is currently broken and includes debug data for a failed attempt at rewriting the insert_edge logic