diff --git a/Tutorial_BioEM/Euler_Angle_List_Prior b/Tutorial_BioEM/Euler_Angle_List_Prior
index 9e684c122b71a607786ea978dcafa1676c1fe7fb..da43a30feb3d9d35ed8201882cf33f2a97b2d292 100644
--- a/Tutorial_BioEM/Euler_Angle_List_Prior
+++ b/Tutorial_BioEM/Euler_Angle_List_Prior
@@ -6,4 +6,3 @@
     0.836000    1.369000    2.640000    0.640000
    -1.375000    0.400000    3.018000    0.360000
    -1.375000    0.400000    3.018000    0.360000
-    0.836000    1.369000    2.640000    0.640000
diff --git a/Tutorial_BioEM/Param_Input_Priors b/Tutorial_BioEM/Param_Input_Priors
index 152236188344a8536b206851932e7e7782f14b00..9167f6817f0e48c6441df2c634c72acb111816f2 100644
--- a/Tutorial_BioEM/Param_Input_Priors
+++ b/Tutorial_BioEM/Param_Input_Priors
@@ -16,4 +16,4 @@ DISPLACE_CENTER 10 2
 
 ####### Priors ###############
 PRIOR_MODEL 0.005
-PRIOR_ANGLES
+#PRIOR_ANGLES
diff --git a/Tutorial_BioEM/Param_Input_Quat b/Tutorial_BioEM/Param_Input_Quat
index 4a25c1b2187974a386e5afeb616e006eafdd295a..92f5f095f16127a8e4f93e8b71bab4179067110d 100644
--- a/Tutorial_BioEM/Param_Input_Quat
+++ b/Tutorial_BioEM/Param_Input_Quat
@@ -4,7 +4,7 @@ PIXEL_SIZE 1.77
 
 ##### Quaterion grid points: #######
 USE_QUATERNIONS
-GRIDPOINTS_QUATERNION 5
+#GRIDPOINTS_QUATERNION 5
 
 ##### Constrast transfer integration: #######
 CTF_B_FACTOR 100.0 300.5 8
diff --git a/Tutorial_BioEM/Param_Input_Short b/Tutorial_BioEM/Param_Input_Short
index 946da802c7a4eb42e7b5a876ae72a38181ffd4e8..586ffab17ed2b3538994ba26e23cbed080c27d87 100644
--- a/Tutorial_BioEM/Param_Input_Short
+++ b/Tutorial_BioEM/Param_Input_Short
@@ -3,11 +3,11 @@ PIXEL_SIZE 1.77
 GRIDPOINTS_ALPHA 10 
 GRIDPOINTS_BETA  5
 GRIDPOINTS_ENVELOPE 4
-START_ENVELOPE 0.0002
-END_ENVELOPE 0.0012
+START_ENVELOPE 0.002
+END_ENVELOPE 0.012
 GRIDPOINTS_PSF_PHASE 4
 START_PSF_PHASE 0.004
-END_PSF_PHASE 0.016
+END_PSF_PHASE 0.06
 GRIDPOINTS_PSF_AMP 1
 START_PSF_AMP 1.
 END_PSF_AMP 1.
diff --git a/bioem.cpp b/bioem.cpp
index 85c5cc46cd34541abe65f4471ffbf30e23e191a0..9b3d9dcc7a93ac16d786751750bfa3d4bc51bf7c 100644
--- a/bioem.cpp
+++ b/bioem.cpp
@@ -266,7 +266,7 @@ int bioem::configure(int ac, char* av[])
       // ********************* Reading Parameter Input ***************************
       if(!param.printModel){
 	// Standard definition for BioEM
-	param.readParameters(infile.c_str(),Inputanglefile.c_str());
+	param.readParameters(infile.c_str());
 
 	// ********************* Reading Particle Maps Input **********************
 	RefMap.readRefMaps(param, mapfile.c_str());
@@ -290,7 +290,7 @@ int bioem::configure(int ac, char* av[])
         exit(1);
       }
 
-    if(!param.printModel)param.CalculateGridsParam();
+    if(!param.printModel)param.CalculateGridsParam(Inputanglefile.c_str());
     }
 #ifdef WITH_MPI
   if (mpi_size > 1)
@@ -298,8 +298,7 @@ int bioem::configure(int ac, char* av[])
       if (DebugOutput >= 2 && mpi_rank == 0) timer.ResetStart();
       MPI_Bcast(&param, sizeof(param), MPI_BYTE, 0, MPI_COMM_WORLD);
 
-  cout << "HERE MPI" << param.nTotGridAngles << " "<< param.nTotGridAngles  * sizeof(myfloat3_t*) << "\n";
-//if (mpi_rank != 0)param.angles = (myfloat3_t*) mallocchk( 4 * param.nTotGridAngles  * sizeof(myfloat_t*));
+//  cout << "HERE MPI " << param.nTotGridAngles << " " << param.nTotGridAngles  * sizeof(myfloat3_t*) << "\n";
    if (mpi_rank != 0)param.angles =  (myfloat3_t*) mallocchk(3 * param.nTotGridAngles  * sizeof (myfloat3_t*));
      MPI_Bcast(param.angles, 3 * param.nTotGridAngles  * sizeof (myfloat3_t*),MPI_BYTE, 0, MPI_COMM_WORLD);
 
@@ -309,11 +308,11 @@ int bioem::configure(int ac, char* av[])
   //  param.angprior = new myfloat_t[param.NotUn_angles] ;
 
 //
-//#ifdef PILAR_DEBUG
+#ifdef PILAR_DEBUG
 	for(int n=0;n<param.nTotGridAngles;n++){
 	  cout << "CHECK: Angle orient " << mpi_rank << " "<< n << " " <<  param.angles[n].pos[0] << " " <<  param.angles[n].pos[1] << " " << param.angles[n].pos[2] << " " << param.angles[n].quat4  << " " << "\n";} 
-//
-//#endif
+
+#endif
       //refCtf, CtfParam, angles automatically filled by precalculare function below
 
       MPI_Bcast(&Model, sizeof(Model), MPI_BYTE, 0, MPI_COMM_WORLD);
@@ -499,6 +498,9 @@ int bioem::run()
 
   if (DebugOutput >= 1 && mpi_rank == 0) printf("\tMain Loop GridAngles %d, CTFs %d, RefMaps %d, Shifts (%d/%d)², Pixels %d², OMP Threads %d, MPI Ranks %d\n", param.nTotGridAngles, param.nTotCTFs, RefMap.ntotRefMap, 2 * param.param_device.maxDisplaceCenter + param.param_device.GridSpaceCenter, param.param_device.GridSpaceCenter, param.param_device.NumberPixels, omp_get_max_threads(), mpi_size);
 
+  if(mpi_size > param.nTotGridAngles){
+    cout << "EXIT: Wrong MPI setup More MPI processes than orientations\n"; exit(1);
+  }
   const int iOrientStart = (int) ((long long int) mpi_rank * param.nTotGridAngles / mpi_size);
   int iOrientEnd = (int) ((long long int) (mpi_rank + 1) * param.nTotGridAngles / mpi_size);
   if (iOrientEnd > param.nTotGridAngles) iOrientEnd = param.nTotGridAngles;
diff --git a/include/param.h b/include/param.h
index 3a72c9bd9a29d7aed3f033c7d97bb7cfb146cf82..f0711cb349edb305ccb3bd30411e3b56ae17f34c 100644
--- a/include/param.h
+++ b/include/param.h
@@ -39,8 +39,8 @@ public:
 	~bioem_param();
 
 
-	int readParameters(const char* fileinput,const char* fileangles);
-	int CalculateGridsParam();
+	int readParameters(const char* fileinput);
+	int CalculateGridsParam(const char* fileangles);
 	int CalculateRefCTF();
         int forprintBest(const char* fileinput);
 	void PrepareFFTs();
@@ -85,8 +85,8 @@ public:
 
 	bool withnoise;
         myfloat_t stnoise;
-        std::string inanglef;
-	std::string quatfile;
+//        std::string inanglef;
+//	std::string quatfile;
 
 	int numberGridPointsDisplaceCenter;
 // Grid sampling for the convolution kernel
diff --git a/map.cpp b/map.cpp
index c902616d84a4d7926a957a4027c67d70db6c21d4..6d0caf5e0242f3e64e7aefcefe91de6e30dd263e 100644
--- a/map.cpp
+++ b/map.cpp
@@ -139,7 +139,7 @@ int bioem_RefMap::readRefMaps(bioem_param& param, const char* filemap)
       char tmpLine[512] = {0};
       bool first=true;
 
-      int countpix;
+      int countpix=0;
 
       while (!input.eof())
 	{
@@ -221,7 +221,6 @@ int bioem_RefMap::readRefMaps(bioem_param& param, const char* filemap)
       ntotRefMap = nummap + 1;
       maps = (myfloat_t*) reallocchk(maps, refMapSize * sizeof(myfloat_t) * ntotRefMap);
       cout << "Particle Maps read from Standard File: " << ntotRefMap << "\n";
-
     }
 
 //Dumping Maps
diff --git a/param.cpp b/param.cpp
index 86a8805f0a377551c3fe4599158ba8f90ec99122..ea246d837491c5016a38a8934cb1ba66ebc6a318 100644
--- a/param.cpp
+++ b/param.cpp
@@ -52,7 +52,7 @@ bioem_param::bioem_param()
   printModel = false;
 }
 
-int bioem_param::readParameters(const char* fileinput,const char* fileangles)
+int bioem_param::readParameters(const char* fileinput)
 {	// **************************************************************************************
 	// ***************************** Reading Input Parameters ******************************
 	// **************************************************************************************
@@ -89,7 +89,7 @@ int bioem_param::readParameters(const char* fileinput,const char* fileangles)
   yespriorAngles=false; 
 
   //Storing angle file name if existing. 
-  inanglef=std::string(fileangles);
+//f(notuniformangles)inanglef=std::string(fileangles);
   NotUn_angles=0;
   priorMod=1; //Default
 
@@ -695,7 +695,7 @@ void bioem_param::releaseFFTPlans()
   fft_plans_created = 0;
 }
 
-int bioem_param::CalculateGridsParam() //TO DO FOR QUATERNIONS
+int bioem_param::CalculateGridsParam(const char* fileangles) //TO DO FOR QUATERNIONS
 {
   // **************************************************************************************
   // **************** Routine that pre-calculates Euler angle grids **********************
@@ -731,7 +731,7 @@ int bioem_param::CalculateGridsParam() //TO DO FOR QUATERNIONS
 
       angles = (myfloat3_t*) mallocchk( 3 * angleGridPointsAlpha * angleGridPointsBeta * angleGridPointsAlpha * sizeof(myfloat3_t));
 
-      cout << "HERE" << sizeof(myfloat3_t) << " " << sizeof(myfloat_t)  << " "<< 4 * angleGridPointsAlpha * angleGridPointsBeta * angleGridPointsAlpha * sizeof(myfloat_t*) << "\n";
+
       for (int ialpha = 0; ialpha < angleGridPointsAlpha; ialpha ++)
 	{
 	  for (int ibeta = 0; ibeta < angleGridPointsBeta; ibeta ++)
@@ -746,23 +746,22 @@ int bioem_param::CalculateGridsParam() //TO DO FOR QUATERNIONS
 		}
 	    }
 	}
-     cout << "HERE2 "<< n <<" " << angleGridPointsAlpha * angleGridPointsBeta * angleGridPointsAlpha << "\n";
       nTotGridAngles = n;
       voluang= grid_alpha * grid_alpha * cos_grid_beta / (2.f * M_PI) / (2.f * M_PI) / 2.f * priorMod;
 
     } else{
 
-      ifstream input(inanglef.c_str());
-
-
+      ifstream input(fileangles);
 
       if (!input.good())
 	{
-	  cout << "Euler Angle File Failed to open file " <<  inanglef.c_str() << " " << endl ;
+	  cout << "Euler Angle File Failed to open file " <<  fileangles << " " << endl ;
 	  exit(1);
 	}
 
       char line[512] = {0};
+//      char saveline[512];
+
       int n=0;
 
       // First line tels the number of rows
@@ -783,8 +782,7 @@ int bioem_param::CalculateGridsParam() //TO DO FOR QUATERNIONS
 
      // NotUn_angles=NotUn_angles+1;
 
-      //elete[] angles; 
-      //  angles = new myfloat3_t[]
+
       angles = (myfloat3_t*) mallocchk( NotUn_angles * 3 * sizeof(myfloat3_t));
 
       if(yespriorAngles){
@@ -793,16 +791,48 @@ int bioem_param::CalculateGridsParam() //TO DO FOR QUATERNIONS
       }
       while (!input.eof())
 	{
+
+	input.getline(line, 511);
+
+ if(n< NotUn_angles){
+
+/*
+         myfloat_t or1,or2,or3,or4,prior; 
+
 	  input.getline(line, 511);
-	  if(n< NotUn_angles){
-	    float a,b,g,pp;
+          strcpy(saveline, line);
+          char *token = strtok(line, " ");
+    if (token == NULL || line[0] == '#' || strlen(token) == 0)
+        {
+          // comment or blank line
+        }
+      else if (strcmp(token, "ORIENT") == 0)
+        {
+          token = strtok(NULL, " ");
+          or1 = atof(token);
+          token = strtok(NULL, " ");
+          or2 = atof(token);
+          token = strtok(NULL, " ");
+          or3 = atof(token);
+          token = strtok(NULL, " ");
+          or4 = atof(token);
+          cout << "TT " << n << " " << or1 << " " << or2 << " " << or3 << " " << or4 << "\n ";
+
+          angles[n].pos[0] = or1;
+            angles[n].pos[1] = or2;
+            angles[n].pos[2] = or3;
+            angles[n].quat4 =0.0;
+       n++;
+      }*/
+
+
+            float a=0.,b=0.,g=0.,pp=0.;
             
 	    char tmpVals[60] = {0};
 
-	    strncpy (tmpVals, line, 12);
+            strncpy (tmpVals, line, 12);
 	    sscanf (tmpVals, "%f", &a);
 
-	    cout << tmpVals <<"\n";
 	    strncpy (tmpVals, line + 12, 12);
 	    sscanf (tmpVals, "%f", &b);
 
@@ -815,11 +845,13 @@ int bioem_param::CalculateGridsParam() //TO DO FOR QUATERNIONS
               if(pp <0.0000001)cout << "Sure you're input is correct? Very small prior.\n";
 	      angprior[n] = (myfloat_t) pp; 
 	    }
+            
             angles[n].pos[0] = (myfloat_t) a;
 	    angles[n].pos[1] = (myfloat_t) b;
 	    angles[n].pos[2] = (myfloat_t) g;
             angles[n].quat4 =0.0;//just to be sure */
-	    if(yespriorAngles) cout << "check orient: " << n << " " << angles[n].pos[0] << " " << angles[n].pos[1] << " " << angles[n].pos[2] << " prior: " << angprior[n] << "\n";
+
+    if(yespriorAngles) cout << "check orient: " << n << " " << " " << angles[n].pos[0] << " " << angles[n].pos[1] << " " << angles[n].pos[2] << " prior: " << angprior[n]<< "\n";
 	  }
 	  n++;
 	  if(NotUn_angles+1 < n) {
@@ -831,7 +863,7 @@ int bioem_param::CalculateGridsParam() //TO DO FOR QUATERNIONS
 	}
       nTotGridAngles = NotUn_angles;
       voluang= 1./ (myfloat_t) NotUn_angles * priorMod;
-      input.close();
+    input.close();
     }
     
   } else {
@@ -909,12 +941,12 @@ int bioem_param::CalculateGridsParam() //TO DO FOR QUATERNIONS
 
 	
       //  ifstream input(quatfile);
-      ifstream input(inanglef.c_str());
+      ifstream input(fileangles);
       //	 ifstream input("QUATERNION_LIST");
 
       if (!input.good())
 	{
-	  cout << "Problem with Quaterion List file " <<  inanglef.c_str() << " " << endl ;
+	  cout << "Problem with Quaterion List file " <<  fileangles << " " << endl ;
 	  exit(1);
 	}