Optimize and fix infinite loop in drawForest