Partial merge of the data migration code.