     <div key={'mm' + metadata.id}>{metadata.AuthorId}: {data.value}</div>
 
   _renderThreadNamesAndMessages: ->
-    names = []
-    messages = []
+    elements = []
     for thread, object of @state.threadNames
-      messageTree = threadStore.getTree thread
+      if not @state.threadTrees or thread not of @state.threadTrees
+        continue
       # Perform a traversal on the tree and print out all the messages
-      queue = [messageTree]
-      while queue.length and queue[0]
-        debugger
+      queue = []
+      for node in @state.threadTrees[thread].children
+        queue.push node
+      while queue.length
         messageNode = queue.shift()
-        message = messageStore.getMessage(messageNode.id)
-        messages.push @_renderMessage message
+
+        # If the message isn't loaded yet, don't keep traversing
+        if messageNode.id not of @state.messages
+          continue
+        message = @state.messages[messageNode.id]
+        elements.push @_renderMessage message
         for node in messageNode.children
           queue.push node
 
+      elements.push(<div key={thread}>{object.displayName}</div>)
 
-      names.push(<div key={thread}>{object.displayName}</div>)
-    return names
+    return elements
 
   render: ->
     return (

    if 'threadNames' not of @state
      threadNames = threadStore.getThreadNames()
      @setState {threadNames}

  _onCursorStoreUpdate: (threadId) ->
    console.log "Got cursor for threadId: ", threadId, cursorStore.getCursor(threadId)

  componentDidMount: ->
    @unsubscribeFromCursorStore = cursorStore.listen(@_onCursorStoreUpdate)
    @unsubscribeFromThreadStore = threadStore.listen(@_onThreadStoreUpdate)
    @unsubscribeFromUserSessionStore = userSessionStore.listen(@_onUserSessionUpdate)


Home = React.createClass
  getInitialState: ->
    user = userSessionStore.getUser()
    state = {
      threadTrees: {}
      messages: {}
    }
    if user?
      state.user = user

    return state

  _onUserSessionUpdate: (user) ->
    @setState {user}
