Clean up treegen code

Created before #308, but I never got around to merging it apparently.
Both pulls include changes worthy of merging.
Trunks should replace also existing leaves, else you get cripple trees when placed near