     AUTOSAVE_DELAY = 100
     aceChangedDebounced = _.debounce(aceChanged, AUTOSAVE_DELAY, false)
 
-    aceLoaded = (editor) ->
+    setup = (editor) ->
       promised.editor = editor
-      setupAce()
-      console.log 'Ace editor loaded!'
+      editor.setShowPrintMargin(false)
+      loadLocalSave()
+      editor.focus()
 
       editor.getSelection().on('changeCursor', aceChangedDebounced)
 
-    # Quick fix to prevent aceLoaded from being fired twice in quick succession.
+    # Quick fix to prevent setup from being fired twice in quick succession.
     # Eventually we should figure out what's causing it to be fired in quick
     # succession in the first place.
-    aceLoadedDebounced = _.debounce(aceLoaded, 100, true)
+    setupDebounced = _.debounce(setup, 100, true)
 
     $scope.aceChanged = -> aceChangedDebounced()
-    $scope.aceLoaded = (args...) -> aceLoadedDebounced(args...)
+    $scope.aceLoaded = (args...) -> setupDebounced(args...)
     $scope.sendEditorData = ->
       editor = promised.editor
       value = editor.getValue()

      position = editor.getCursorPosition()
      line = position.row + 1
      column = position.column
      editor_state = {}
      editor_state.value = value
      editor_state.line = line
      editor_state.column = column
      storage.set('student_code', editor_state)
      #localStorage.edit__autosave_value = value
      #localStorage.edit__autosave_line = line
      #localStorage.edit__autosave_column = column
      console.log 'Autosaved'

    setupAce = ->
      editor = promised.editor
      editor.setShowPrintMargin(false)
      loadLocalSave()
      editor.focus()


    aceChanged = ->
      doLocalSave()

DEFAULT_VALUE = '''
# what will you create?
'''

angular.module('edit', ['ui.ace'])
.controller 'EditCtrl', [
  '$scope'
  ($scope) ->

    promised = {}
