fix onEnd and onBegin not copied to this.