Cleaned up event handling