Factor out pubsub for eventual replacement. More testing of the same.