cleanup of event handlers and added comments