             or (info.direction is 'pull' and info.change.docs_written > 0)
                 needTreeRebuild = rebuildFs
 
-        # Called only for a continuous replication
-        .on 'uptodate', (info) ->
+            log.info changeMessage
+
+        onUptoDate = (info) ->
             log.info 'Replication is complete'
             if needTreeRebuild
                 log.info 'Applying changes on the filesystem'
                 applyChanges ->
                     needTreeRebuild = false
 
-        # Called only for a single replication
-        .on 'complete', (info) ->
+        onComplete = (info) ->
             log.info 'Replication is complete'
             if fromRemote and not toRemote
                 log.info 'Applying changes on the filesystem'

                    filesystem.watchingLocked = false
                    callback null

        # Do not need rebuild until docs are added
        needTreeRebuild = false

        # Set authentication
        url = urlParser.parse remoteConfig.url
        url.auth = "#{deviceName}:#{remoteConfig.devicePassword}"

        # Launch replication
        replicate(urlParser.format(url) + 'cozy', options)
        .on 'change', (info) ->
            changeMessage = "DB change: #{info.change.docs_written} doc(s) written"
            if info.direction
                # Specify direction

                doc.docType is 'Folder' or doc.docType is 'File'
            live: continuous

        # Do not need rebuild until docs are added
        needTreeRebuild = false

        # Set authentication
        url = urlParser.parse remoteConfig.url
        url.auth = "#{deviceName}:#{remoteConfig.devicePassword}"

        # Define action after replication completion
        applyChanges = (callback) ->

