fix for to_portable_primitive