pubsub: refactor (fixes #98).