Moved the publisher- and subscriber-related code to new classes