Added debug and test code for avl