diff --git a/DDG4/src/Geant4GeneratorWrapper.cpp b/DDG4/src/Geant4GeneratorWrapper.cpp
index 7eb09b3f5303949a23841fd8d5d7162bc185a0bf..b79bed2f665ddf1214d1aa85503324839c793dfb 100644
--- a/DDG4/src/Geant4GeneratorWrapper.cpp
+++ b/DDG4/src/Geant4GeneratorWrapper.cpp
@@ -78,10 +78,12 @@ void Geant4GeneratorWrapper::operator()(G4Event* event)  {
   generator()->GeneratePrimaryVertex(event);
 
   /// Add all the missing interactions (primary vertices) to the primary event record.
+  int maskCounter = 100000 + m_mask;
   for(G4PrimaryVertex* gv=event->GetPrimaryVertex(); gv; gv=gv->GetNext())  {
     if ( primaries.find(gv) == primaries.end() )   {
-      Geant4PrimaryInteraction* inter = createPrimary(m_mask, primaryMap, gv);
-      prim->add(m_mask, inter);
+      Geant4PrimaryInteraction* inter = createPrimary(maskCounter, primaryMap, gv);
+      prim->add(maskCounter, inter);
+      maskCounter += 1;
     }
   }
 }
diff --git a/DDG4/src/Geant4InputHandling.cpp b/DDG4/src/Geant4InputHandling.cpp
index fdc1468f52ae4d5a1e1f43782b305d1afd2f2101..e75a4f26f69488b8ad73cdd1b550b418a28c6cf8 100644
--- a/DDG4/src/Geant4InputHandling.cpp
+++ b/DDG4/src/Geant4InputHandling.cpp
@@ -180,13 +180,14 @@ static void appendInteraction(const Geant4Action* caller,
   }
   Geant4PrimaryInteraction::VertexMap::iterator ivfnd, iv, ivend;
   for( iv=input->vertices.begin(), ivend=input->vertices.end(); iv != ivend; ++iv )   {
-    ivfnd = output->vertices.find((*iv).first) ; //(*iv).second->mask);
+    int theMask = input->mask;
+    ivfnd = output->vertices.find(theMask);
     if ( ivfnd != output->vertices.end() )   {
       caller->abortRun("Duplicate primary interaction identifier!",
                        "Cannot handle 2 interactions with identical identifiers!");
     }
     for(Geant4Vertex* vtx :  (*iv).second )
-      output->vertices[(*iv).first].emplace_back( vtx->addRef() );
+      output->vertices[theMask].emplace_back( vtx->addRef() );
   }
 }