Rework low-level handling of Datatype handles