treetable: big refactor