Factor input and output handlers into classes

Break the input and output handlers into classes and initialize
them so multiple routes between inputs and outputs can be configured
in config.json.