     return null
 
 add_context = (code='') ->
-  context = get_available_context()
-  if context?
-    context.editor.setValue code
-  else
-    context = create_input_cell $document, code
-    contexts.push context
-  {editor} = context
+  cell = get_available_context()
+  if cell?
+    cell.editor.setValue code
+  else
+    cell = create_input_cell code
+    $document.append cell.$el
+    cell.rendered()
+    contexts.push cell
+
+  {editor} = cell
   editor.focus()
   editor.setCursor(line: editor.lineCount() - 1)
-  context
+  cell
 
 run_in_available_context = (code) ->
   add_context(code).run()
   add_context()
 
 # Add an input cell above the last input cell
-run_in_info_context = (code) ->
+run_in_info_context = (current_cell, code) ->
   last = contexts[contexts.length - 1]
-  $target = $ '<div/>'
-  if last
-    last.$el.before $target
-  else
-    $document.append $target
-  context = create_input_cell $target, code
-  contexts.splice -1, 0, context
-  context.run code
-
-create_input_cell = ($target, code) ->
+  cell = create_input_cell code
+  if current_cell?
+    current_cell.$el.before cell.$el
+    index = contexts.indexOf cell
+  else
+    $document.append cell.$el
+    index = -1
+  cell.rendered()
+  contexts.splice index, 0, cell
+  cell.run code
+
+create_input_cell = (code) ->
   $el = $ '<div class="cell input"/>'
   $code = $ '<div class="code"/>'
   $el.append $code
-
-  $target.append $el
 
   editor = CodeMirror $code.get(0),
     value: code

  run_context =
    current_options: {}
    default_options: default_options
    output: ($document) ->
      $item = $ '<div class="item"/>'
      if $document?
        $item.append $document
      $el.append $item
      $item
    success: ->

  cur = cm.getCursor()
  token = cm.getTokenAt(cur)
  if lead.graphite.has_docs token.string
    run_in_info_context cm.lead_cell, "docs '#{token.string}'"
  else if lead.ops[token.string]?
    run_in_info_context cm.lead_cell, "help #{token.string}"

CodeMirror.commands.suggest = (cm) ->
  CodeMirror.showHint cm, suggest, async: true
