diff --git a/demo/chatdialog.cpp b/demo/chatdialog.cpp
index 34f5682..b7edf20 100644
--- a/demo/chatdialog.cpp
+++ b/demo/chatdialog.cpp
@@ -17,7 +17,7 @@
   DigestTreeScene *scene = new DigestTreeScene();
 
   treeViewer->setScene(scene);
-  scene->plot();
+  //scene->plot();
 
   connect(lineEdit, SIGNAL(returnPressed()), this, SLOT(returnPressed()));
   connect(setButton, SIGNAL(pressed()), this, SLOT(buttonPressed()));
@@ -53,8 +53,8 @@
 
 void
 ChatDialog::formChatMessage(const QString &text, SyncDemo::ChatMessage &msg) {
-  msg.set_from(m_nick.toStdString());
-  msg.set_to(m_chatroom.toStdString());
+  msg.set_from(m_user.getNick().toStdString());
+  msg.set_to(m_user.getChatroom().toStdString());
   msg.set_data(text.toStdString());
   time_t seconds = time(NULL);
   msg.set_timestamp(seconds);
@@ -64,29 +64,34 @@
 ChatDialog::readSettings()
 {
   QSettings s(ORGANIZATION, APPLICATION);
-  m_nick = s.value("nick", "").toString();
-  m_chatroom = s.value("chatroom", "").toString();
-  m_prefix = s.value("prefix", "").toString();
-  if (m_nick == "" || m_chatroom == "" || m_prefix == "") {
+  QString nick = s.value("nick", "").toString();
+  QString chatroom = s.value("chatroom", "").toString();
+  QString prefix = s.value("prefix", "").toString();
+  if (nick == "" || chatroom == "" || prefix == "") {
     QTimer::singleShot(500, this, SLOT(buttonPressed()));
   }
+  else {
+    m_user.setNick(nick);
+    m_user.setChatroom(chatroom);
+    m_user.setPrefix(prefix);
+  }
 }
 
 void 
 ChatDialog::writeSettings()
 {
   QSettings s(ORGANIZATION, APPLICATION);
-  s.setValue("nick", m_nick);
-  s.setValue("chatroom", m_chatroom);
-  s.setValue("prefix", m_prefix);
+  s.setValue("nick", m_user.getNick());
+  s.setValue("chatroom", m_user.getChatroom());
+  s.setValue("prefix", m_user.getPrefix());
 }
 
 void
 ChatDialog::updateLabels()
 {
-  QString settingDisp = QString("<User: %1>, <Chatroom: %2>").arg(m_nick).arg(m_chatroom);
+  QString settingDisp = QString("<User: %1>, <Chatroom: %2>").arg(m_user.getNick()).arg(m_user.getChatroom());
   infoLabel->setText(settingDisp);
-  QString prefixDisp = QString("<Prefix: %1>").arg(m_prefix);
+  QString prefixDisp = QString("<Prefix: %1>").arg(m_user.getPrefix());
   prefixLabel->setText(prefixDisp);
 }
 
@@ -111,7 +116,7 @@
 void
 ChatDialog::buttonPressed()
 {
-  SettingDialog dialog(this, m_nick, m_chatroom, m_prefix);
+  SettingDialog dialog(this, m_user.getNick(), m_user.getChatroom(), m_user.getPrefix());
   connect(&dialog, SIGNAL(updated(QString, QString, QString)), this, SLOT(settingUpdated(QString, QString, QString)));
   dialog.exec();
 }
@@ -120,17 +125,17 @@
 ChatDialog::settingUpdated(QString nick, QString chatroom, QString prefix)
 {
   bool needWrite = false;
-  if (!nick.isEmpty() && nick != m_nick) {
-    m_nick = nick;
+  if (!nick.isEmpty() && nick != m_user.getNick()) {
+    m_user.setNick(nick);
     needWrite = true;
   }
-  if (!prefix.isEmpty() && prefix != m_prefix) {
-    m_prefix = prefix;
+  if (!prefix.isEmpty() && prefix != m_user.getPrefix()) {
+    m_user.setPrefix(prefix);
     needWrite = true;
     // TODO: set the previous prefix as left?
   }
-  if (!chatroom.isEmpty() && chatroom != m_chatroom) {
-    m_chatroom = chatroom;
+  if (!chatroom.isEmpty() && chatroom != m_user.getChatroom()) {
+    m_user.setChatroom(chatroom);
     needWrite = true;
     // TODO: perhaps need to do a lot. e.g. use a new SyncAppSokcet
   }
diff --git a/demo/chatdialog.h b/demo/chatdialog.h
index 337f20f..3ae668b 100644
--- a/demo/chatdialog.h
+++ b/demo/chatdialog.h
@@ -33,9 +33,7 @@
   void settingUpdated(QString, QString, QString);
 
 private:
-  QString m_nick;
-  QString m_chatroom;
-  QString m_prefix;
+  User m_user; 
   Sync::SyncAppSocket *m_sock;
 };
 #endif
diff --git a/demo/digesttreescene.cpp b/demo/digesttreescene.cpp
index 483f1f6..2d2f631 100644
--- a/demo/digesttreescene.cpp
+++ b/demo/digesttreescene.cpp
@@ -6,6 +6,7 @@
 #include <vector>
 #include <iostream>
 #include <assert.h>
+#include <boost/lexical_cast.hpp>
 
 static const double Pi = 3.14159265358979323846264338327950288419717;
 
@@ -15,86 +16,176 @@
 }
 
 void
-DigestTreeScene::plot() {
+DigestTreeScene::processUpdate(std::vector<Sync::MissingDataInfo> &v, QString digest)
+{
+  int n = v.size();
+  bool rePlot = false; 
+  for (int i = 0; i < n; i++) 
+  {
+    Roster_iterator it = m_roster.find(v[i].prefix.c_str());
+    if (it == m_roster.end()) {
+      rePlot = true; 
+      DisplayUserPtr p(new DisplayUser());
+      p->setPrefix(v[i].prefix.c_str());
+      p->setSeq(v[i].high);
+      m_roster.insert(p->getPrefix(), p);
+    }
+  }
+
+  if (rePlot) 
+  {
+    plot(digest);
+  }
+  else 
+  {
+    for (int i = 0; i < n; i++) 
+    {
+      Roster_iterator it = m_roster.find(v[i].prefix.c_str());
+      if (it != m_roster.end()) {
+        DisplayUserPtr p = it.value();
+        QGraphicsTextItem *item = p->getSeqTextItem();
+        std::string s = boost::lexical_cast<std::string>(p->getSeqNo().getSeq());
+        item->setPlainText(s.c_str());
+      }
+    }
+    m_rootDigest->setPlainText(digest);
+  }
+}
+
+void
+DigestTreeScene::msgReceived(QString prefix, QString nick)
+{
+  Roster_iterator it = m_roster.find(prefix);
+  if (it != m_roster.end()) 
+  {
+    DisplayUserPtr p = it.value();
+    if (nick != p->getNick()) {
+      p->setNick(nick);
+      QGraphicsTextItem *nickItem = p->getNickTextItem();
+      nickItem->setPlainText(p->getNick());
+    }
+    QGraphicsRectItem *rimItem = p->getRimRectItem();
+    rimItem->setBrush(QBrush(Qt::red));
+  }
+}
+
+void
+DigestTreeScene::plot(QString digest)
+{
   clear();
   m_graph.clear();
-  std::vector<ogdf::node> v(5);
-  for (int i = 0; i < 5; i++)
-    v[i] = m_graph.newNode();
-
-  m_graph.newEdge(v[0], v[1]);
-  m_graph.newEdge(v[0], v[2]);
-  m_graph.newEdge(v[0], v[3]);
-  m_graph.newEdge(v[0], v[4]);
-
+  int n = m_roster.size();
+  ogdf::node root = m_graph.newNode();
+  int rootIndex = root->index();
+  for (int i = 0; i < n; i++) {
+     ogdf::node leaf = m_graph.newNode();
+     m_graph.newEdge(root, leaf);
+  }
   ogdf::GraphAttributes GA(m_graph);
-  GA.initAttributes(ogdf::GraphAttributes::nodeLabel);
-  int nodeWidth = 30, nodeHeight = 30, siblingDistance = 60;
+
+  int nodeSize = 50;
+  int siblingDistance = 100, levelDistance = 100;
   ogdf::TreeLayout layout;
   layout.siblingDistance(siblingDistance);
-  layout.rootSelection(ogdf::TreeLayout::rootIsSource);
-  //layout.call(GA);
+  layout.levelDistance(levelDistance);
   layout.callSortByPositions(GA, m_graph);
 
   int width = GA.boundingBox().width();
-  std::cout << "GA width " << width << std::endl;
   int height = GA.boundingBox().height();
-  std::cout << "GA height " << height << std::endl;
-  setSceneRect(QRect(0, 0, width + nodeWidth, height + nodeHeight));
-  GA.setAllWidth(nodeWidth);
-  GA.setAllHeight(nodeHeight);
+  setSceneRect(QRect(- (width + nodeSize) / 2, - 40, width + nodeSize, height + nodeSize));
+  GA.setAllWidth(nodeSize);
+  GA.setAllHeight(nodeSize);
 
+  plotEdge(GA);
+  plotNode(GA, rootIndex, digest);
+
+}
+
+void
+DigestTreeScene::plotEdge(ogdf::GraphAttributes &GA)
+{
   ogdf::edge e;
   forall_edges(e, m_graph) {
     ogdf::node source = e->source();
     ogdf::node target = e->target();
+    int nodeSize = GA.width(target);
     int x1 = GA.x(source), y1 = -GA.y(source);
     int x2 = GA.x(target), y2 = -GA.y(target);
-  //  QPainterPath p;
-    QPointF src(x1 + nodeWidth/2, y1 + nodeHeight/2);
-    QPointF dest(x2 + nodeWidth/2, y2 + nodeHeight/2);
+    QPointF src(x1 + nodeSize/2, y1 + nodeSize/2);
+    QPointF dest(x2 + nodeSize/2, y2 + nodeSize/2);
     QLineF line(src, dest);
-    //p.moveTo(x1 + nodeWidth/2, y1 + nodeHeight/2);
-    //p.lineTo(x2 + nodeWidth/2, y2 + nodeHeight/2);
-    //addPath(p, QPen(Qt::black), QBrush(Qt::black));
-    addLine(line, QPen(Qt::black));
-    
     double angle = ::acos(line.dx() / line.length());
 
     double arrowSize = 10;
-
-   QPointF sourceArrowP0 = src + QPointF(nodeWidth/2 * line.dx() / line.length(),  nodeHeight/2 * line.dy() / line.length());
-   //QPointF sourceArrowP0 = src + QPointF(cos(angle) * nodeHeight/2, sin(angle) * nodeHeight/2);
-
-   std::cout << "src " << src.x() << ", " << src.y() << std::endl;
-   std::cout << "dest " << dest.x() << ", " << dest.y() << std::endl;
-   std::cout << "line dx " << line.dx() << ", dy " << line.dy() << ", lenght << " << line.length() << std::endl;
-   std::cout << "sap " << sourceArrowP0.x() << ", " << sourceArrowP0.y() << std::endl;
-
-   QPointF sourceArrowP1 = sourceArrowP0 + QPointF(cos(angle + Pi / 3 - Pi/2) * arrowSize,
+    QPointF sourceArrowP0 = src + QPointF((nodeSize/2 + 10) * line.dx() / line.length(),  (nodeSize/2 +10) * line.dy() / line.length());
+    QPointF sourceArrowP1 = sourceArrowP0 + QPointF(cos(angle + Pi / 3 - Pi/2) * arrowSize,
                                                     sin(angle + Pi / 3 - Pi/2) * arrowSize);
-      QPointF sourceArrowP2 = sourceArrowP0 + QPointF(cos(angle + Pi - Pi / 3 - Pi/2) * arrowSize,
+    QPointF sourceArrowP2 = sourceArrowP0 + QPointF(cos(angle + Pi - Pi / 3 - Pi/2) * arrowSize,
                                                          sin(angle + Pi - Pi / 3 - Pi/2) * arrowSize);
-    QLineF line1(sourceArrowP1, sourceArrowP2);
-    addLine(line1, QPen(Qt::black));
-     
-     addPolygon(QPolygonF() << sourceArrowP0<< sourceArrowP1 << sourceArrowP2, QPen(Qt::black), QBrush(Qt::black));
-  }
 
+    addLine(QLineF(sourceArrowP0, dest), QPen(Qt::black));
+    addPolygon(QPolygonF() << sourceArrowP0<< sourceArrowP1 << sourceArrowP2, QPen(Qt::black), QBrush(Qt::black));
+  }
+}
+
+void
+DigestTreeScene::plotNode(ogdf::GraphAttributes &GA, int rootIndex, QString digest)
+{
   ogdf::node n;
-  int i = 0;
-  std::string s[5] = {"A", "B", "C", "D", "E"};
+  RosterIterator it(m_roster);
   forall_nodes(n, m_graph) {
     double x = GA.x(n);
-
     double y = -GA.y(n);
     double w = GA.width(n);
     double h = GA.height(n);
+    int rim = 3;
     QRectF boundingRect(x, y, w, h);
-    addEllipse(boundingRect, QPen(Qt::black), QBrush(Qt::green));
-    QGraphicsTextItem *text = addText(s[i].c_str());
-    text->setPos(x + 5, y + 5);
-    i++; 
+    QRectF innerBoundingRect(x + rim, y + rim, w - rim * 2, h - rim * 2);
+    addRect(innerBoundingRect, QPen(Qt::black), QBrush(Qt::lightGray));
+
+    if (n->index() == rootIndex) 
+    {
+      addRect(boundingRect, QPen(Qt::black), QBrush(Qt::darkRed));
+
+      QRectF digestRect(x - w / 2, y - h - 5, 2 * w, 30);
+      addRect(digestRect, QPen(Qt::darkCyan), QBrush(Qt::darkCyan));
+      QGraphicsTextItem *digestItem = addText(digest);
+      QRectF digestBoundingRect = digestItem->boundingRect();
+      digestItem->setDefaultTextColor(Qt::white);
+      digestItem->setFont(QFont("Cursive", 12, QFont::Bold));
+      digestItem->setPos(x + w / 2 - digestBoundingRect.width() / 2, y - h - 15);
+      m_rootDigest = digestItem;
+    }
+    else
+    {
+      if (it.hasNext()) 
+      {
+        it.next();
+      }
+      else 
+      {
+        abort();
+      }
+      DisplayUserPtr p = it.value();
+      QGraphicsRectItem *rectItem = addRect(boundingRect, QPen(Qt::black), QBrush(Qt::darkBlue));
+      p->setRimRectItem(rectItem);
+
+      std::string s = boost::lexical_cast<std::string>(p->getSeqNo().getSeq());
+      QGraphicsTextItem *seqItem = addText(s.c_str());
+      seqItem->setFont(QFont("Cursive", 12, QFont::Bold));
+      QRectF seqBoundingRect = seqItem->boundingRect(); 
+      seqItem->setPos(x + w / 2 - seqBoundingRect.width() / 2, y + h / 2 - seqBoundingRect.height() / 2);
+      p->setSeqTextItem(seqItem);
+
+      QRectF textRect(x - w / 2, y + h + 10, 2 * w, 30);
+      addRect(textRect, QPen(Qt::darkCyan), QBrush(Qt::darkCyan));
+      QGraphicsTextItem *nickItem = addText(p->getNick());
+      QRectF textBoundingRect = nickItem->boundingRect();
+      nickItem->setDefaultTextColor(Qt::white);
+      nickItem->setFont(QFont("Cursive", 12, QFont::Bold));
+      nickItem->setPos(x + w / 2 - textBoundingRect.width() / 2, y + h + 15);
+      p->setNickTextItem(nickItem);
+    }
   }
 }
 
diff --git a/demo/digesttreescene.h b/demo/digesttreescene.h
index 1915c2f..5c8af9d 100644
--- a/demo/digesttreescene.h
+++ b/demo/digesttreescene.h
@@ -4,15 +4,79 @@
 #include <QtGui/QGraphicsScene>
 #include "ogdf/basic/GraphAttributes.h"
 #include "ogdf/basic/Graph.h"
+#include <sync-seq-no.h>
+#include <sync-logic.h>
+#include <ctime>
+#include <QMap>
+#include <vector>
+#include <tr1/memory>
+
+class QGraphicsTextItem;
+
+class User;
+class DisplayUser;
 
 class DigestTreeScene : public QGraphicsScene
 {
   Q_OBJECT
 
+typedef std::tr1::shared_ptr<DisplayUser> DisplayUserPtr;
+typedef QMap<QString, DisplayUserPtr> Roster;
+typedef QMap<QString, DisplayUserPtr>::iterator Roster_iterator;
+typedef QMapIterator<QString, DisplayUserPtr> RosterIterator;
+
 public:
   DigestTreeScene(QWidget *parent = 0);
-  void plot();
+  void processUpdate(std::vector<Sync::MissingDataInfo> &v, QString digest);
+  void msgReceived(QString prefix, QString nick);
+  void plot(QString digest);
+  void plotEdge(ogdf::GraphAttributes &GA);
+  void plotNode(ogdf::GraphAttributes &GA, int rootIndex, QString digest);
 private:
   ogdf::Graph m_graph;
+  Roster m_roster;
+  QGraphicsTextItem *m_rootDigest; 
+
 };
+
+class User 
+{
+public:
+  User():m_received(time(NULL)) {}
+  User(QString n, QString p, QString c): m_nick(n), m_prefix(p), m_chatroom(c), m_received(time(NULL)) {}
+  void setNick(QString nick) {m_nick = nick;}
+  void setPrefix(QString prefix) {m_prefix = prefix;}
+  void setChatroom(QString chatroom) {m_chatroom = chatroom;}
+  void setSeq(Sync::SeqNo seq) {m_seq = seq;}
+  void setReceived() {m_received = time(NULL);}
+  QString getNick() { return m_nick;}
+  QString getPrefix() { return m_prefix;}
+  QString getChatroom() { return m_chatroom;}
+  Sync::SeqNo getSeqNo() { return m_seq;}
+  time_t getReceived() { return m_received;}
+private:
+  QString m_nick;
+  QString m_prefix;
+  QString m_chatroom;
+  Sync::SeqNo m_seq;
+  time_t m_received;
+};
+
+class DisplayUser : public User 
+{
+public:
+  DisplayUser():m_seqTextItem(NULL), m_nickTextItem(NULL), m_rimRectItem(NULL) {}
+  DisplayUser(QString n, QString p , QString c): User(n, p, c), m_seqTextItem(NULL), m_nickTextItem(NULL), m_rimRectItem(NULL) {}
+  QGraphicsTextItem *getSeqTextItem() {return m_seqTextItem;}
+  QGraphicsTextItem *getNickTextItem() {return m_nickTextItem;}
+  QGraphicsRectItem *getRimRectItem() {return m_rimRectItem;}
+  void setSeqTextItem(QGraphicsTextItem *item) { m_seqTextItem = item;}
+  void setNickTextItem(QGraphicsTextItem *item) { m_nickTextItem = item;}
+  void setRimRectItem(QGraphicsRectItem *item) {m_rimRectItem = item;}
+private:
+  QGraphicsTextItem *m_seqTextItem;
+  QGraphicsTextItem *m_nickTextItem;
+  QGraphicsRectItem *m_rimRectItem;
+};
+
 #endif
