Cleaned tree code.