Fixed NPE in event handling.