Fixed an issue with event handler not being initialized correctly