Added treegen()