Fix type loading to also handle locally defined types and inner classes.