diff --git a/sbe-tool/src/main/golang/otf/irdecoder.go b/sbe-tool/src/main/golang/otf/irdecoder.go
index 794ec99cd5..58a052f999 100644
--- a/sbe-tool/src/main/golang/otf/irdecoder.go
+++ b/sbe-tool/src/main/golang/otf/irdecoder.go
@@ -330,8 +330,9 @@ func (decoder *IrDecoder) updateComponentTokenCounts(tokens []Token) {
 		} else if strings.HasPrefix(signal.String(), "End") {
 			componentType := signal.String()[3:]
 			beginIndices := beginIndexMap[componentType]
-			beginIndex := beginIndices[0]
-			beginIndexMap[componentType] = beginIndices[1:]
+			last := len(beginIndices) - 1
+			beginIndex := beginIndices[last]
+			beginIndexMap[componentType] = beginIndices[:last]
 			componentTokenCount := int32((i - beginIndex) + 1)
 			tokens[beginIndex].componentTokenCount = componentTokenCount
 			token.componentTokenCount = componentTokenCount
diff --git a/sbe-tool/src/main/golang/otf/token.go b/sbe-tool/src/main/golang/otf/token.go
index 1e812ce2db..442b6d5d80 100644
--- a/sbe-tool/src/main/golang/otf/token.go
+++ b/sbe-tool/src/main/golang/otf/token.go
@@ -104,6 +104,14 @@ func (token Token) TokenVersion() int32 {
 	return token.version
 }
 
+// ApplicableTypeName returns the name of the type that should be applied in context.
+func (token Token) ApplicableTypeName() string {
+	if token.referencedName == "" {
+		return token.name
+	}
+	return token.referencedName
+}
+
 func (token Token) Encoding() Encoding {
 	return token.encoding
 }