Copy over some fixes from SD5.
Fix InvalidCastException in InconsistentNamingIssue.