 changeStyle = (theme) ->
   $('body').attr('id', theme)
 
-create_session = (document, to_load) ->
+create_session = (doc, to_load) ->
 
   ####################
   # Settings
   ####################
 
-  settings = new Settings document.store, {mainDiv: $settingsDiv}
+  settings = new Settings doc.store, {mainDiv: $settingsDiv}
 
   changeStyle (settings.getSetting 'theme')
   $settingsDiv.find(".theme-selection").val (settings.getSetting 'theme')

  # session
  ####################

  session = new Session document, {
    bindings: key_bindings
    settings: settings
    mainDiv: $('#view'),

  # datastore = new DataStore.ChromeStorageLazy

  datastore = new DataStore.InMemory
  doc = new Document datastore
  chrome.storage.sync.get 'save', (results) ->
    create_session doc, (results.save or constants.default_data)

    # save every 5 seconds
    setInterval (() ->
      chrome.storage.sync.set {
        'save': doc.serialize()
      }, () ->
        # TODO have whether saved visualized
        Logger.logger.info 'Saved'
