Added treegen code.