[common] cleanup avl and related code

First effort towards #666