Changed r->d and l->u in edit_tuples()