Clean up treegen code (@ShadowNinja)