Refactor of TreeView class.