Improved restoration script