First commit, copying reduced tree code from Adam.
First commit, copying reduced tree code from Adam.