         @shadow                = @_copy(@live)
         @backup_shadow         = @_copy(@shadow)
         @shadow_version        = 0
-        @last_version_received = 0
+        @backup_shadow_version = 0
+        @last_version_received = -1
         @edit_stack            = []
 
     status: () =>

            console.log("#{@id} -- shadow changes: '#{@shadow}' --> '#{snapshot}'  (version #{@shadow_version+1})")
            @shadow = snapshot
            @shadow_version += 1
        else
            # console.log("#{@id} -- push_edits -- (nothing new)")

        # Push any remaining edits from the stack, *AND* report the last version we have received so far.
        @server.recv_edits @edit_stack, @last_version_received, cb

    # Receive and process the edits from the other end of the sync connection.
    recv_edits: (edit_stack, last_version_ack, cb) =>

        if Math.random() < .5
            cb?(true)
            return

        #console.log("#{@id} -- recv_edits -- #{misc.to_json(edit_stack)}")
        # Keep only edits that we still need to send.
        @edit_stack = (edits for edits in @edit_stack when edits.shadow_version > last_version_ack)

        #console.log("#{@id} -- remaining queued edits for next time: ", @edit_stack)
        # process the incoming edits
        for edits in edit_stack
            console.log("#{@id} -- our shadow version = #{@shadow_version} and other shadow version #{edits.shadow_version}")
            # If edits.shadow_version does not equal @shadow_version, then there was a packet duplication or loss.
            if edits.shadow_version < @shadow_version
                console.log("Duplicate Packet: we have no interest in edits we have already processed.")
                continue
            else if edits.shadow_version > @shadow_version
                @restart('shadow_version out of sync')
            else if edits.shadow_checksum != @_checksum(@shadow)
                # Data corruption in memory or network -- there should be no other way for this to happen.
                # In this case, we have to just restart everything from scratch.
                console.log("#{@id}: shadow = #{@shadow}, version = #{@shadow_version}")
                @restart("checksum (edit_stack=#{misc.to_json(edit_stack)})")
            else
                # Everything looks golden.
                @last_version_received = edits.shadow_version
                console.log("#{@id} -- shadow changes: '#{@shadow}' --> '#{@_apply_edits(edits.edits, @shadow)}' (version #{@shadow_version+1})")
                @shadow = @_apply_edits(edits.edits, @shadow)
                @shadow_version += 1
                @live = @_apply_edits(edits.edits, @live)
                @backup_shadow = @_copy(@shadow)

        cb?()



    go()
    client.live += "\nmore stuff"
    server.live = 'bar' + server.live
    status()
    while client.live != server.live
        try
