diff --git a/NPLib/scripts/NPToolLogon.C b/NPLib/scripts/NPToolLogon.C
index ab0007dcdf5686dfafb5eceda75cd3d470b3c083..15e82b5731c356cea4b693d952df95cda961372f 100644
--- a/NPLib/scripts/NPToolLogon.C
+++ b/NPLib/scripts/NPToolLogon.C
@@ -20,16 +20,18 @@
  *                                                                           *
  *                                                                           *
  *****************************************************************************/
+
+// C++ headers
+#include <iostream>
+#include <vector>
+using namespace std;
+
 // ROOT headers
 #include "TSystem.h"
 #include "TROOT.h"
 #include "TList.h"
 #include "TSystemDirectory.h"
 #include "TString.h"
- 
-// C++ headers
-#include <iostream>
-using namespace std;
 
 void NPToolLogon(bool quietmode = false)
 {
diff --git a/NPSimulation/src/MUST2Array.cc b/NPSimulation/src/MUST2Array.cc
index e644c5950b1859f5bd080eb362d7aff080be8042..321e478c5934f2b541960c892115d63cec1b3581 100644
--- a/NPSimulation/src/MUST2Array.cc
+++ b/NPSimulation/src/MUST2Array.cc
@@ -1156,7 +1156,7 @@ void MUST2Array::ReadSensitive(const G4Event* event)
 
 	        // Pos X
 	        Pos_X_itr = PosXHitMap->GetMap()->begin();
-	        for (G4int h = 0 ; h < sizeX ; h++) {
+	        for (G4int h = 0 ; h < PosXHitMap->entries() ; h++) {
 	            G4int PosXTrackID =   Pos_X_itr->first  - N   ;
 	            G4double PosX     = *(Pos_X_itr->second)      ;
 	            if (PosXTrackID == NTrackID) {
@@ -1167,7 +1167,7 @@ void MUST2Array::ReadSensitive(const G4Event* event)
 
 	        // Pos Y
 	        Pos_Y_itr = PosYHitMap->GetMap()->begin();
-	        for (G4int h = 0 ; h < sizeX ; h++) {
+	        for (G4int h = 0 ; h < PosYHitMap->entries() ; h++) {
 	            G4int PosYTrackID =   Pos_Y_itr->first  - N   ;
 	            G4double PosY     = *(Pos_Y_itr->second)      ;
 	            if (PosYTrackID == NTrackID) {
@@ -1178,7 +1178,7 @@ void MUST2Array::ReadSensitive(const G4Event* event)
 
 	        // Pos Z
 	        Pos_Z_itr = PosZHitMap->GetMap()->begin();
-	        for (G4int h = 0 ; h < sizeX ; h++) {
+	        for (G4int h = 0 ; h < PosZHitMap->entries() ; h++) {
 	            G4int PosZTrackID =   Pos_Z_itr->first   - N  ;
 	            G4double PosZ     = *(Pos_Z_itr->second)      ;
 	            if (PosZTrackID == NTrackID) {
@@ -1189,7 +1189,7 @@ void MUST2Array::ReadSensitive(const G4Event* event)
 
 	        // Angle Theta
 	        Ang_Theta_itr = AngThetaHitMap->GetMap()->begin();
-	        for (G4int h = 0 ; h < sizeX ; h++) {
+	        for (G4int h = 0 ; h < AngThetaHitMap->entries(); h++) {
 	            G4int AngThetaTrackID =   Ang_Theta_itr->first  - N   ;
 	            G4double AngTheta     = *(Ang_Theta_itr->second)      ;
 	            if (AngThetaTrackID == NTrackID) {
@@ -1200,7 +1200,7 @@ void MUST2Array::ReadSensitive(const G4Event* event)
 
 	        // Angle Phi
 	        Ang_Phi_itr = AngPhiHitMap->GetMap()->begin();
-	        for (G4int h = 0 ; h < sizeX ; h++) {
+	        for (G4int h = 0 ; h < AngPhiHitMap->entries() ; h++) {
 	            G4int AngPhiTrackID =   Ang_Phi_itr->first  - N   ;
 	            G4double AngPhi     = *(Ang_Phi_itr->second)      ;
 	            if (AngPhiTrackID == NTrackID) {