treetable: very big refactor