Add dispatching to handler functions
Convert some examples to use handlers.