Using reduce to walk tree by node index and some beauty fixes