So this assumes the final argument to `handler` is a callback function. Totally need to be super-explicit about this, maybe even `assert` it in the code, better an assert fail than something like `Cannot call method `apply` of undefined`.