cleaned up treegen code

cleaned up treegen