Fix the memory leak in remove_event