I tried ref counting and it worked quite well. One thing puzzled me, however - when I declared a destructor for a class to be protected, I could still call delete on an object of this class - something that you can't do in C++ - is it the expected behaviour of D or just a bug in the compiler?