   constructor: (options = {}, data)->
 
     options.domId    = 'kdmaincontainer'
+    options.cssClass = if KD.isLoggedInOnLoad then 'with-sidebar' else ''
 
     super options, data
 
     @notifications = []
 
-  viewAppended:->
+
+  viewAppended: ->
+
+    {mainController} = KD.singletons
 
     @bindPulsingRemove()
     @bindTransitionEnd()
     @createHeader()
-    @createMainPanels()
+
+    if KD.isLoggedInOnLoad
+    then @createSidebar()
+    else mainController.once 'accountChanged.to.loggedIn', @bound 'createSidebar'
+
+    @createPanelWrapper()
     @createMainTabView()
 
-    KD.singletons.mainController.ready =>
-      @createAccountArea()
+    mainController.ready =>
+      if KD.isLoggedInOnLoad
+      then @createAccountArea()
+      else mainController.once 'accountChanged.to.loggedIn', @bound 'createAccountArea'
+
       @setStickyNotification()
       @emit 'ready'
 
-  createMainPanels:->
-
-    @addSubView @panelWrapper = new KDView
-      tagName  : "section"
-      domId    : "main-panel-wrapper"
 
   createHeader:->
 


    @header.clear()

    @header.addSubView @headerContainer = new KDCustomHTMLView
      cssClass  : "inner-container"

    @logo = new KDCustomHTMLView
      tagName   : "a"
      domId     : "koding-logo"
      cssClass  : if entryPoint?.type is 'group' then 'group' else ''

        then router.handleRoute '/Activity', {entryPoint}
        else router.handleRoute '/', {entryPoint}

    @logo.setClass KD.config.environment

    @header.addSubView @logotype = new CustomLinkView
      cssClass : 'logotype'
      title    : 'Koding'
      href     : '/Home'


  createSidebar: ->

    @setClass 'with-sidebar'

    @addSubView @sidebar = new KDCustomHTMLView
      tagName  : 'aside'
      domId    : 'main-sidebar'

    @sidebar.addSubView KD.singletons.dock.getView()


  createPanelWrapper:->

    @addSubView @panelWrapper = new KDView
      tagName  : 'section'
      domId    : 'main-panel-wrapper'


  createAccountArea:->

    @sidebar.addSubView @accountArea = new KDCustomHTMLView
      cssClass : 'account-area'

    if KD.isLoggedIn()
    then @createLoggedInAccountArea()
    else
      mc = KD.getSingleton "mainController"
      mc.once "accountChanged.to.loggedIn", @bound 'createLoggedInAccountArea'

