The latest code is restore4.py. There are descriptions of earlier versions in the 'historical' directory. Earlier code has been removed because later versions work significantly better.