Speed up sendEvent by using direct function calls and `call` instead of `apply` where possible