Maybe this code could be merged with the equivalent lines in the `Restore` class.