ugtrain: reduce pointer access cascading

We have a lot of accesses like this: struct1->struct2->value. This
makes code difficult to read and repeats a lot of pointer accesses.
So use temporary variables to reduce pointer access cascading. The
compiler is able to optimize so that there aren't any variables or
pointers copied. Functionality remains the same.

Looks like this:
struct2_type *struct2 = struct1->struct2;
something = struct2->value;