Unifying marshalling/unmarshalling code