Fixed bug in build_forest()