Rewrite Restore functionality.

Includes main edge case.