Added an auto-release pool to the dispatch event function. This ensures any resources allocated during this will be released at the end of the event function call.