util: Allow GClass.addToString to include fields in base classes.

Currently this is limited to base classes that are in the same
GDirectory as the GClass itself.
util: Fix base class import getting added after imports were output.