Preventing downcasting when the object can be null and other refactoring

preventing direct down casting with out checking for null as some of the member fields of the Event can be null. Refactoring is done to make the code precise rather than using intermediate variables instead of directly assigning the value and use of generic Object type unnecessarily.