Reorganize code to support recording of latest_revisions.