I think it would be worth adding a line to reset restoreTime to null here so that restoreTime is only set when we need to be restored.