add locking to subscriptions ,correctly track acks, cleanup, doc