Updated tree code and commented