Cleaned up event handling.