moved thread local free(events) to end of function