Optimizing topic publisher and subscriber code and adding comments