=== modified file 'src/DensityGrid.cpp'
--- src/DensityGrid.cpp	2009-10-14 13:51:48 +0000
+++ src/DensityGrid.cpp	2011-03-15 14:34:40 +0000
@@ -44,6 +44,8 @@
 #include "drl_Node.h"
 #include "DensityGrid.h"
 
+#define GET_BIN(y, x) (Bins[y*GRID_SIZE+x])
+
 namespace drl {
 
 //*******************************************************
@@ -71,7 +73,7 @@
     {
       Density = new float[GRID_SIZE][GRID_SIZE];
       fall_off = new float[RADIUS*2+1][RADIUS*2+1];
-      Bins = new deque<Node>[GRID_SIZE][GRID_SIZE];
+      Bins = new deque<Node>[GRID_SIZE*GRID_SIZE];
     }
   catch (bad_alloc errora)
     {
@@ -88,7 +90,7 @@
   for (i=0; i< GRID_SIZE; i++) 
     for (int j=0; j< GRID_SIZE; j++) {
       Density[i][j] = 0;
-      Bins[i][j].erase(Bins[i][j].begin(),Bins[i][j].end());
+      GET_BIN(i, j).erase(GET_BIN(i, j).begin(), GET_BIN(i, j).end());
     }
   
   // Compute fall off
@@ -100,7 +102,6 @@
 	
 }
 
-
 /***************************************************
  * Function: DensityGrid::GetDensity               *
  * Description: Get_Density from density grid      *
@@ -129,14 +130,13 @@
 			for(int j=x_grid-1; j<=x_grid+1; j++) {
 
 			// Look through bin and add fine repulsions
-			for(BI = Bins[i][j].begin(); BI < Bins[i][j].end(); ++BI) {
+			for(BI = GET_BIN(i, j).begin(); BI != GET_BIN(i, j).end(); ++BI) {
 				x_dist =  Nx-(BI->x);
 				y_dist =  Ny-(BI->y);
 				distance = x_dist*x_dist+y_dist*y_dist;
 				density += 1e-4/(distance + 1e-50);
 		 }
 		}
-
 	// Course density
 	} else {
 
@@ -250,7 +250,7 @@
   /* Where to subtract */
   x_grid = (int)((N.sub_x+HALF_VIEW+.5)*VIEW_TO_GRID);
   y_grid = (int)((N.sub_y+HALF_VIEW+.5)*VIEW_TO_GRID);
-  Bins[y_grid][x_grid].pop_front();
+  GET_BIN(y_grid, x_grid).pop_front();
 }
 
 /***************************************************
@@ -266,7 +266,7 @@
   y_grid = (int)((N.y+HALF_VIEW+.5)*VIEW_TO_GRID);
   N.sub_x = N.x;
   N.sub_y = N.y;
-  Bins[y_grid][x_grid].push_back(N);
+  GET_BIN(y_grid, x_grid).push_back(N);
 }
 
 } // namespace drl

=== modified file 'src/DensityGrid.h'
--- src/DensityGrid.h	2009-10-14 13:51:48 +0000
+++ src/DensityGrid.h	2011-03-15 14:34:40 +0000
@@ -74,7 +74,7 @@
 	  // new dynamic variables -- SBM
 	  float (*fall_off)[RADIUS*2+1];
 	  float (*Density)[GRID_SIZE];
-	  deque<Node> (*Bins)[GRID_SIZE];
+	  deque<Node>* Bins;
 
 	  // old static variables
 	  //float fall_off[RADIUS*2+1][RADIUS*2+1];

=== modified file 'src/DensityGrid_3d.cpp'
--- src/DensityGrid_3d.cpp	2009-10-14 13:51:48 +0000
+++ src/DensityGrid_3d.cpp	2011-03-15 14:34:40 +0000
@@ -44,6 +44,8 @@
 #include "drl_Node_3d.h"
 #include "DensityGrid_3d.h"
 
+#define GET_BIN(z, y, x) (Bins[(z*GRID_SIZE+y)*GRID_SIZE+x])
+
 namespace drl3d {
 
 //*******************************************************
@@ -71,7 +73,7 @@
     {
       Density = new float[GRID_SIZE][GRID_SIZE][GRID_SIZE];
       fall_off = new float[RADIUS*2+1][RADIUS*2+1][RADIUS*2+1];
-      Bins = new deque<Node>[GRID_SIZE][GRID_SIZE][GRID_SIZE];
+      Bins = new deque<Node>[GRID_SIZE*GRID_SIZE*GRID_SIZE];
     }
   catch (bad_alloc errora)
     {
@@ -89,7 +91,7 @@
     for (int j=0; j< GRID_SIZE; j++) 
       for (int k=0; k < GRID_SIZE; k++) {
 	Density[i][j][k] = 0;
-	Bins[i][j][k].erase(Bins[i][j][k].begin(),Bins[i][j][k].end());
+	GET_BIN(i,j,k).erase(GET_BIN(i,j,k).begin(),GET_BIN(i,j,k).end());
       }
   
   // Compute fall off
@@ -136,7 +138,7 @@
 	      for(int j=x_grid-1; j<=x_grid+1; j++) {
 		      
 		// Look through bin and add fine repulsions
-		for(BI = Bins[k][i][j].begin(); BI < Bins[k][i][j].end(); ++BI) {
+		for(BI = GET_BIN(k,i,j).begin(); BI < GET_BIN(k,i,j).end(); ++BI) {
 		  x_dist =  Nx-(BI->x);
 		  y_dist =  Ny-(BI->y);
 		  z_dist =  Nz-(BI->z);
@@ -267,7 +269,7 @@
   x_grid = (int)((N.sub_x+HALF_VIEW+.5)*VIEW_TO_GRID);
   y_grid = (int)((N.sub_y+HALF_VIEW+.5)*VIEW_TO_GRID);
   z_grid = (int)((N.sub_z+HALF_VIEW+.5)*VIEW_TO_GRID);
-  Bins[z_grid][y_grid][x_grid].pop_front();
+  GET_BIN(z_grid,y_grid,x_grid).pop_front();
 }
 
 /***************************************************
@@ -285,7 +287,7 @@
   N.sub_x = N.x;
   N.sub_y = N.y;
   N.sub_z = N.z;
-  Bins[z_grid][y_grid][x_grid].push_back(N);
+  GET_BIN(z_grid,y_grid,x_grid).push_back(N);
 }
 
 } // namespace drl3d

=== modified file 'src/DensityGrid_3d.h'
--- src/DensityGrid_3d.h	2009-10-14 13:51:48 +0000
+++ src/DensityGrid_3d.h	2011-03-15 14:34:40 +0000
@@ -74,7 +74,7 @@
 	  // new dynamic variables -- SBM
 	  float (*fall_off)[RADIUS*2+1][RADIUS*2+1];
 	  float (*Density)[GRID_SIZE][GRID_SIZE];
-	  deque<Node> (*Bins)[GRID_SIZE][GRID_SIZE];
+	  deque<Node>* Bins;
 
 	  // old static variables
 	  //float fall_off[RADIUS*2+1][RADIUS*2+1];

