[common] cleanup avl and related code

First effort towards #666
Done, landed at bdf3b9b