Fixed memory leak on event change