Fix state saving in the case of long download