Fix ArrayDims method
Free string buffers allocated by hdf5 library
Remove duplicated code
Avoid copying datatypes unnecessarily

No need to lock the compound datatype.
If locked, it cannot be packed for instance.
Update some comments
Close datatypes explicitely

…to prevent the need for damage control!