Refactor channel model: pipe events to a central channel keyed by type.
Various logic improvements suggested by kibit.
Merge pull request #8 from DavidGregory084/refact-listener

Refactor channel model: pipe events to a central channel keyed by type.