chg: refactoring for corpus restore.