       ledger.api.BlockRestClient.instance.refreshLastBlock()
       @_deleteSynchronizationToken(@_syncToken) if @_syncToken?
       @_syncToken = null
+      duration = moment.duration(new Date().getTime() - startDate.getTime())
+      $info "Stop synchronization. Synchronization took #{duration.get("minutes")}:#{duration.get("seconds")}:#{duration.get("milliseconds")}"
       @stopIfNeccessary()
 
   _performRecovery: (unconfirmedTransactions) ->
     syncToken = null
     savedState = {}
+    persistState = no
     @_loadSynchronizationData().then (data) =>
-      savedState = data
+      savedState = @_migrateSavedState(data)
+      persistState = yes
       @_requestSynchronizationToken()
     .then (token) =>
       @_syncToken = token


  onStart: () ->
    unconfirmedTxs = @_findUnconfirmedTransaction()
    @_performRecovery(unconfirmedTxs).then (transactionsNotFound) =>
      l "Recovery completed"
      @_discardTransactions(transactionsNotFound)


class ledger.tasks.WalletLayoutRecoveryTask extends ledger.tasks.Task

  BatchSize: 100

  constructor: -> super 'recovery-global-instance'

