Add onBegin and onEnd callbacks