More robust restore, fix empty file bug for dump