Fixed NPE when handling null events