Fix up uses of the AVL tree to use templates correctly