Fixed memory leak with events