Cleaned up insert node function.

Still retain known issue where inserting a node breaks d3.