Update to grade tree code - still not finished