 
         # The remote server sends data back to us to display:
         @scrollbar_nlines = 0
+        @value = ''
         @session.on 'data',  (data) =>
-            console.log("SERVER --> CLIENT: '#{data}'")
             try
-
                 @terminal.write(data)
+                @value += data.replace(/\x1b\[.{1,5}m|\x1b\].*0;|\x1b\[.*~|\x1b\[?.*l/g,'')
 
                 if @scrollbar_nlines < @terminal.ybase
-                    while @scrollbar_nlines < @terminal.ybase
-                        @scrollbar.append($("<br>"))
-                        @scrollbar_nlines += 1
-                @set_scrollbar_to_term()
+                    @update_scrollbar()
+
+                setTimeout(@set_scrollbar_to_term, 10)
 
             catch e
                 # TODO -- these are all basically bugs, I think...

        # We wait until the first write completes before enabling this.
        @first_response = true
        @terminal.on 'data',  (data) =>
            console.log("CLIENT --> SERVER: '#{data}'")
            if @first_response
                @first_response = false
                console.log("scrollbar_nlines = ", @scrollbar_nlines)
                console.log("@terminal.ybase = ", @terminal.ybase)
                if @scrollbar_nlines > 0  # reconnect
                    return


            # nothing implemented
            return
        @terminal.refresh(0, @opts.rows-1)
        @resize_scrollbar()


    # Determine the current size (rows and columns) of the DOM
