Factor out dispatch to its own module.