Added beforeedit and afteredit callbacks