piecewise tree structure
split library and ui; other changes