fix packing/unpacking