Fix datatype handle management in use-defined datarep callbacks