Fixed onBeforeApply and onBeforeCancel, too