optimize invokeEvent,changes param types and modifiers for invokeEvent and $dispatchEvent methods