Added recovery functionality. Totally untested.