 
     # Init values for changes
 
+    maximum_latency = 1000
     startcontent = editor.doc.getValue()
     queue = []
+    send_all_content = false
+    remote_edit_timeout = null
     has_remote_edits = false
     sort_by_time = (a,b) ->
         if a.time < b.time

            })
            rerender_editor_from_queue()

            socket.emit 'change',
                change: changeObj,
                all_content: editor.doc.getValue(),



    socket.on 'remote_change', (change) ->
        has_remote_edits = true

        window.clearTimeout(remote_edit_timeout)
        remote_edit_timeout = window.setTimeout ->
            has_remote_edits = false
            startcontent = editor.doc.getValue()
            queue = []

        , maximum_latency

        queue.push({
            time: change.time,
            change: change.change
        })
        # rerender_editor_from_queue()
        history = editor.doc.getHistory()
        editor.doc.replaceRange(
            change.change.text, 
            change.change.from, 
            change.change.to, 
            'remote'
        )
        editor.doc.setHistory(history)

        # var cursor_coords = editor.cursorCoords(changeObj.to)
        # console.log(cursor_coords)
