Rewriting undispatched event code