better tree selection; removed debug code