Adapt some code for datashape migration