Initial implementation of rewrite, with deletion and keep working.

Still, created nodes can still overlap with nodes already in the graph.