Clean up treegen code