Add rewind logic to deal with post-fork software updates
Includes logic for dealing with pruning by Suhas Daftuar.