Cleaned up the event handler.