Clean up the lifecycle of data handles. This is a huge commit that also
involves the core data management in ARX. Although all tests succeed, it
most probably introduces bugs.