fixed free(events) segfault