diff --git a/src/digest-tree-scene.cpp b/src/digest-tree-scene.cpp
index 88315b1..65204df 100644
--- a/src/digest-tree-scene.cpp
+++ b/src/digest-tree-scene.cpp
@@ -9,7 +9,7 @@
  *         Alexander Afanasyev <alexander.afanasyev@ucla.edu>
  */
 
-#include "digest-tree-scene.h"
+#include "digest-tree-scene.hpp"
 
 #include <QtGui>
 
@@ -21,6 +21,8 @@
 #include <memory>
 #endif
 
+namespace chronos {
+
 static const double Pi = 3.14159265358979323846264338327950288419717;
 
 //DisplayUserPtr DisplayUserNullPtr;
@@ -36,38 +38,32 @@
 {
   int n = v.size();
   bool rePlot = false;
-  for (int i = 0; i < n; i++)
-  {
+  for (int i = 0; i < n; i++) {
     QString routablePrefix(v[i].prefix.c_str());
     QString prefix = trimRoutablePrefix(routablePrefix);
 
     Roster_iterator it = m_roster.find(prefix);
-    if (it == m_roster.end())
-    {
+    if (it == m_roster.end()) {
       // std::cout << "processUpdate v[" << i << "]: " << prefix.toStdString() << std::endl;
       rePlot = true;
       DisplayUserPtr p(new DisplayUser());
-      time_t tempTime = time(NULL) - FRESHNESS + 1;
+      time_t tempTime = ::time(NULL) - FRESHNESS + 1;
       p->setReceived(tempTime);
       p->setPrefix(prefix);
       p->setSeq(v[i].high);
       m_roster.insert(p->getPrefix(), p);
     }
-    else
-    {
+    else {
       it.value()->setSeq(v[i].high);
     }
   }
 
-  if (rePlot)
-  {
+  if (rePlot) {
     plot(digest);
     QTimer::singleShot(2100, this, SLOT(emitReplot()));
   }
-  else
-  {
-    for (int i = 0; i < n; i++)
-    {
+  else {
+    for (int i = 0; i < n; i++) {
       QString routablePrefix(v[i].prefix.c_str());
       QString prefix = trimRoutablePrefix(routablePrefix);
 
@@ -80,7 +76,8 @@
         item->setPlainText(s.c_str());
         QRectF textBR = item->boundingRect();
         QRectF rectBR = rectItem->boundingRect();
-        item->setPos(rectBR.x() + (rectBR.width() - textBR.width())/2, rectBR.y() + (rectBR.height() - textBR.height())/2);
+        item->setPos(rectBR.x() + (rectBR.width() - textBR.width())/2,
+                     rectBR.y() + (rectBR.height() - textBR.height())/2);
       }
     }
     m_rootDigest->setPlainText(digest);
@@ -98,12 +95,10 @@
 {
   QStringList rosterList;
   RosterIterator it(m_roster);
-  while(it.hasNext())
-  {
+  while (it.hasNext()) {
     it.next();
     DisplayUserPtr p = it.value();
-    if (p != DisplayUserNullPtr)
-    {
+    if (p != DisplayUserNullPtr) {
       rosterList << "- " + p->getNick();
     }
   }
@@ -116,33 +111,31 @@
   QString prefix = trimRoutablePrefix(routablePrefix);
   Roster_iterator it = m_roster.find(prefix);
   // std::cout << "msgReceived prefix: " << prefix.toStdString() << std::endl;
-  if (it != m_roster.end())
-    {
-      // std::cout << "Updating for prefix = " << prefix.toStdString() << " nick = " << nick.toStdString() << std::endl;
-      DisplayUserPtr p = it.value();
-      p->setReceived(time(NULL));
-      if (nick != p->getNick())
-        {
-          // std::cout << "old nick = " << p->getNick().toStdString() << std::endl;
-          p->setNick(nick);
-          QGraphicsTextItem *nickItem = p->getNickTextItem();
-          QGraphicsRectItem *nickRectItem = p->getNickRectItem();
-          nickItem->setPlainText(p->getNick());
-          QRectF rectBR = nickRectItem->boundingRect();
-          QRectF nickBR = nickItem->boundingRect();
-          nickItem->setPos(rectBR.x() + (rectBR.width() - nickBR.width())/2, rectBR.y() + 5);
-          emit rosterChanged(QStringList());
-        }
-
-      reDrawNode(p, Qt::red);
-
-      if (previouslyUpdatedUser != DisplayUserNullPtr && previouslyUpdatedUser != p)
-        {
-          reDrawNode(previouslyUpdatedUser, Qt::darkBlue);
-        }
-
-      previouslyUpdatedUser = p;
+  if (it != m_roster.end()) {
+    // std::cout << "Updating for prefix = " << prefix.toStdString() <<
+    // " nick = " << nick.toStdString() << std::endl;
+    DisplayUserPtr p = it.value();
+    p->setReceived(::time(NULL));
+    if (nick != p->getNick()) {
+      // std::cout << "old nick = " << p->getNick().toStdString() << std::endl;
+      p->setNick(nick);
+      QGraphicsTextItem *nickItem = p->getNickTextItem();
+      QGraphicsRectItem *nickRectItem = p->getNickRectItem();
+      nickItem->setPlainText(p->getNick());
+      QRectF rectBR = nickRectItem->boundingRect();
+      QRectF nickBR = nickItem->boundingRect();
+      nickItem->setPos(rectBR.x() + (rectBR.width() - nickBR.width())/2, rectBR.y() + 5);
+      emit rosterChanged(QStringList());
     }
+
+    reDrawNode(p, Qt::red);
+
+    if (previouslyUpdatedUser != DisplayUserNullPtr && previouslyUpdatedUser != p) {
+      reDrawNode(previouslyUpdatedUser, Qt::darkBlue);
+    }
+
+    previouslyUpdatedUser = p;
+  }
 }
 
 void
@@ -163,7 +156,7 @@
 DigestTreeScene::plot(QString digest)
 {
 #ifdef _DEBUG
-  std::cout << "Plotting at time: " << time(NULL) << std::endl;
+  std::cout << "Plotting at time: " << ::time(NULL) << std::endl;
 #endif
   clear();
 
@@ -177,14 +170,11 @@
   // do some cleaning, get rid of stale member info
   Roster_iterator it = m_roster.begin();
   QStringList staleUserList;
-  while (it != m_roster.end())
-  {
+  while (it != m_roster.end()) {
     DisplayUserPtr p = it.value();
-    if (p != DisplayUserNullPtr)
-    {
-      time_t now = time(NULL);
-      if (now - p->getReceived() >= FRESHNESS)
-      {
+    if (p != DisplayUserNullPtr) {
+      time_t now = ::time(NULL);
+      if (now - p->getReceived() >= FRESHNESS) {
 #ifdef _DEBUG
         std::cout << "Removing user: " << p->getNick().toStdString() << std::endl;
         std::cout << "now - last = " << now - p->getReceived() << std::endl;
@@ -193,10 +183,9 @@
         p = DisplayUserNullPtr;
         it = m_roster.erase(it);
       }
-      else
-      {
-        if (!m_currentPrefix.startsWith("/private/local") && p->getPrefix().startsWith("/private/local"))
-        {
+      else {
+        if (!m_currentPrefix.startsWith("/private/local") &&
+            p->getPrefix().startsWith("/private/local")) {
 #ifdef _DEBUG
           std::cout << "erasing: " << p->getPrefix().toStdString() << std::endl;
 #endif
@@ -208,8 +197,7 @@
         ++it;
       }
     }
-    else
-    {
+    else {
       it = m_roster.erase(it);
     }
   }
@@ -243,19 +231,22 @@
     double angle = ::acos(line.dx() / line.length());
 
     double arrowSize = 10;
-    QPointF sourceArrowP0 = src + QPointF((nodeSize/2 + 10) * line.dx() / line.length(),  (nodeSize/2 +10) * line.dy() / line.length());
+    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,
-                                                         sin(angle + Pi - Pi / 3 - Pi/2) * arrowSize);
+                                                    sin(angle + Pi - Pi / 3 - Pi/2) * arrowSize);
 
     addLine(QLineF(sourceArrowP0, dest), QPen(Qt::black));
-    addPolygon(QPolygonF() << sourceArrowP0<< sourceArrowP1 << sourceArrowP2, QPen(Qt::black), QBrush(Qt::black));
+    addPolygon(QPolygonF() << sourceArrowP0<< sourceArrowP1 <<
+               sourceArrowP2, QPen(Qt::black), QBrush(Qt::black));
   }
 }
 
 void
-DigestTreeScene::plotNode(const std::vector<TreeLayout::Coordinate> &childNodesCo, QString digest, int nodeSize)
+DigestTreeScene::plotNode(const std::vector<TreeLayout::Coordinate>& childNodesCo,
+                          QString digest, int nodeSize)
 {
   RosterIterator it(m_roster);
   int n = childNodesCo.size();
@@ -273,20 +264,16 @@
   QRectF digestBoundingRect = digestItem->boundingRect();
   digestItem->setDefaultTextColor(Qt::black);
   digestItem->setFont(QFont("Cursive", 12, QFont::Bold));
-  digestItem->setPos(- 4.5 * nodeSize + (12 * nodeSize - digestBoundingRect.width()) / 2, - nodeSize + 5);
+  digestItem->setPos(- 4.5 * nodeSize + (12 * nodeSize - digestBoundingRect.width()) / 2,
+                     - nodeSize + 5);
   m_rootDigest = digestItem;
 
   // plot child nodes
-  for (int i = 0; i < n; i++)
-  {
+  for (int i = 0; i < n; i++) {
     if (it.hasNext())
-    {
       it.next();
-    }
     else
-    {
       abort();
-    }
 
     double x = childNodesCo[i].x;
     double y = childNodesCo[i].y;
@@ -296,14 +283,17 @@
     QGraphicsRectItem *rectItem = addRect(boundingRect, QPen(Qt::black), QBrush(Qt::darkBlue));
     p->setRimRectItem(rectItem);
 
-    QGraphicsRectItem *innerRectItem = addRect(innerBoundingRect, QPen(Qt::black), QBrush(Qt::lightGray));
+    QGraphicsRectItem *innerRectItem = addRect(innerBoundingRect,
+                                               QPen(Qt::black),
+                                               QBrush(Qt::lightGray));
     p->setInnerRectItem(innerRectItem);
 
     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 + nodeSize / 2 - seqBoundingRect.width() / 2, y + nodeSize / 2 - seqBoundingRect.height() / 2);
+    seqItem->setPos(x + nodeSize / 2 - seqBoundingRect.width() / 2,
+                    y + nodeSize / 2 - seqBoundingRect.height() / 2);
     p->setSeqTextItem(seqItem);
 
     QRectF textRect(x - nodeSize / 2, y + nodeSize, 2 * nodeSize, 30);
@@ -331,7 +321,8 @@
     seqTextItem->setPlainText(s.c_str());
     QRectF textBR = seqTextItem->boundingRect();
     QRectF innerBR = innerItem->boundingRect();
-    seqTextItem->setPos(innerBR.x() + (innerBR.width() - textBR.width())/2, innerBR.y() + (innerBR.height() - textBR.height())/2);
+    seqTextItem->setPos(innerBR.x() + (innerBR.width() - textBR.width())/2,
+                        innerBR.y() + (innerBR.height() - textBR.height())/2);
 }
 
 QString
@@ -340,27 +331,22 @@
   bool encaped = false;
   ndn::Name prefixName(prefix.toStdString());
 
-  ndn::Name::const_iterator it  = prefixName.begin();
-  ndn::Name::const_iterator end = prefixName.end();
   size_t offset = 0;
-
-  for(; it != end; it++, offset++)
-    {
-      if(it->toEscapedString() == "%F0.")
-        {
-          encaped = true;
-          break;
-        }
+  for (ndn::Name::const_iterator it  = prefixName.begin(); it != prefixName.end(); it++, offset++) {
+    if (it->toUri() == "%F0.") {
+      encaped = true;
+      break;
     }
+  }
 
-  if(!encaped)
+  if (!encaped)
     return prefix;
   else
-    {
-      return QString(prefixName.getSubName(offset+1).toUri().c_str());
-    }
+    return QString(prefixName.getSubName(offset+1).toUri().c_str());
 }
 
+} // namespace chronos
+
 #if WAF
 #include "digest-tree-scene.moc"
 #include "digest-tree-scene.cpp.moc"
