added pubsub and some fixes