Fix errors with restore - make it a bit more robust when errors occur.