TODO better edit handling