         query = query.replace(/^\s*$[\n\r]{1,}/gm, '')
         query = query.replace(/\s*$/, '') # Remove the white spaces at the end of the query (like newline/space/tab)
         if window.localStorage?
-            if state.history.length is 0 or state.history[state.history.length-1].query isnt query and @regex.white.test(query) is false
-                state.history.push
+            if dataexplorer_state.history.length is 0 or dataexplorer_state.history[dataexplorer_state.history.length-1].query isnt query and @regex.white.test(query) is false
+                dataexplorer_state.history.push
                     query: query
                     broken_query: broken_query
-                if state.history.length>@size_history
-                    window.localStorage.rethinkdb_history = JSON.stringify state.history.slice state.history.length-@size_history
+                if dataexplorer_state.history.length>@size_history
+                    window.localStorage.rethinkdb_history = JSON.stringify dataexplorer_state.history.slice dataexplorer_state.history.length-@size_history
                 else
-                    window.localStorage.rethinkdb_history = JSON.stringify state.history
+                    window.localStorage.rethinkdb_history = JSON.stringify dataexplorer_state.history
                 @history_view.add_query
                     query: query
                     broken_query: broken_query
 
     clear_history: =>
-        state.history.length = 0
-        window.localStorage.rethinkdb_history = JSON.stringify state.history
+        dataexplorer_state.history.length = 0
+        window.localStorage.rethinkdb_history = JSON.stringify dataexplorer_state.history
 
     # Save the current query (the one in codemirror) in local storage
     save_current_query: =>


    # A portion is one query of the whole input.
    execute_portion: =>
        state.query_result = null
        while @queries[@index]?
            full_query = @non_rethinkdb_query
            full_query += @queries[@index]

        @codemirror.on 'gutterClick', @handle_gutter_click

        @codemirror.setSize '100%', 'auto'
        if dataexplorer_state.current_query?
            @codemirror.setValue dataexplorer_state.current_query
        @codemirror.focus() # Give focus

        # Track if the focus is on codemirror
        # We use it to refresh the docs once the reql_docs.json is loaded
        dataexplorer_state.focus_on_codemirror = true

        @codemirror.setCursor @codemirror.lineCount(), 0
        if @codemirror.getValue() is '' # We show suggestion for an empty query only
