Refactor broker into publisher and subscriber

@tribal-tec ?

This code is untouched from the previous broker.