 
   clear_notebook = (notebook) ->
     notebook.$document.empty()
+    for cell in notebook.cells
+      cell.active = false
     notebook.cells.length = 0
 
   cell_index = (cell) ->

    cell =
      type: 'input'
      $el: $el
      notebook: notebook
      used: false
      editor: editor

    index = cell_index cell
    cell.$el.remove()
    cell.notebook.cells.splice index, 1
    cell.active = false

  hide_cell = (cell) ->
    cell.visible = false
    cell.$el.hide()

  insert_cell = (cell, position={}) ->
    if position.before?.active
      offset = 0
      current_cell = position.before
      current_cell.$el.before cell.$el
    else if position.after?.active
      offset = 1
      current_cell = position.after
      current_cell.$el.after cell.$el
