Speed fix to unpack_loc, so that derived types are only allocated if used.