move tree generation code into treegen; refactor fresh names gen