Improved tree generation