diff --git a/src/partition_allocator/partition_allocator.c b/src/partition_allocator/partition_allocator.c
index a48c1059453baa56cfddb7f74cfd55d2921801e1..1d637066573a1fdc06cded6167ca6eff605fb941 100644
--- a/src/partition_allocator/partition_allocator.c
+++ b/src/partition_allocator/partition_allocator.c
@@ -85,7 +85,7 @@ static int _find_best_path(pa_switch_t *start, int source_port, int *target,
 /* */
 static int _set_best_path(void);
 /* */
-static int _configure_dims(int *coord, int *end);
+static int _configure_dims(int *coord, int *start, int *end);
 /* */
 static int _set_one_dim(int *start, int *end, int *coord);
 
@@ -1045,7 +1045,7 @@ static char *_set_internal_wires(List nodes, int size, int conn_type)
 	for(i=0;i<count;i++) {
 		if(!pa_node[i]->used) {
 			if(size!=1)
-				_configure_dims(pa_node[i]->coord, end);
+				_configure_dims(pa_node[i]->coord, start, end);
 			pa_node[i]->used=1;
 			pa_node[i]->conn_type=conn_type;
 			if(pa_node[i]->letter == '.') {
@@ -1173,8 +1173,17 @@ static int _find_one_hop(pa_switch_t *curr_switch, int source_port,
 			}		
 		}
 	}
-	printf("suck, I didn't find it in one hop dim = %d from port %d\n",dim,source_port);
-	printf("targets from %d%d%d are %d%d%d and %d%d%d\n",node_tar[X],node_tar[Y],node_tar[Z],target[X],target[Y],target[Z],target2[X],target2[Y],target2[Z]);
+/* 	printf("suck, I didn't find it in one hop dim = %d from port %d\n",dim,source_port); */
+/* 	printf("targets from %d%d%d are %d%d%d and %d%d%d\n", */
+/* 	       node_tar[X], */
+/* 	       node_tar[Y], */
+/* 	       node_tar[Z], */
+/* 	       target[X], */
+/* 	       target[Y], */
+/* 	       target[Z], */
+/* 	       target2[X], */
+/* 	       target2[Y], */
+/* 	       target2[Z]); */
 	return 0;
 }
 
@@ -1219,8 +1228,13 @@ static int _find_best_path(pa_switch_t *start, int source_port, int *target,
 		//printf("count = %d\n",count);
 		itr = list_iterator_create(path);
 		while((path_switch = (pa_path_switch_t*) list_next(itr))){
-			//if(dim ==Y)
-			//printf("%d%d%d %d - %d\n", path_switch->geometry[X], path_switch->geometry[Y], path_switch->geometry[Z], path_switch->in,  path_switch->out);
+		/* 	if(dim == Y) */
+/* 				printf("%d%d%d %d - %d\n",  */
+/* 				       path_switch->geometry[X],  */
+/* 				       path_switch->geometry[Y],  */
+/* 				       path_switch->geometry[Z],  */
+/* 				       path_switch->in,   */
+/* 				       path_switch->out); */
 			temp_switch = (pa_path_switch_t *) xmalloc(sizeof(pa_path_switch_t));
 			 
 			temp_switch->geometry[X] = path_switch->geometry[X];
@@ -1311,7 +1325,7 @@ static int _set_best_path(void)
 	return 1;
 }
 
-static int _configure_dims(int *coord, int *end)
+static int _configure_dims(int *coord, int *start, int *end)
 {
 	pa_switch_t *curr_switch; 
 	int dim;
@@ -1323,72 +1337,61 @@ static int _configure_dims(int *coord, int *end)
 	for(dim=0; dim<PA_SYSTEM_DIMENSIONS; dim++) {
 		//printf("Dim %d\n",dim); 
 		curr_switch = &pa_system_ptr->grid[coord[X]][coord[Y]][coord[Z]].axis_switch[dim];
+		
+		target[X]=coord[X];	
+		target2[X]=coord[X];
+		target[Y]=coord[Y];
+		target2[Y]=coord[Y];
+		target[Z]=coord[Z];
+		target2[Z]=coord[Z];
+		
 		if(dim==X) {
-			target[X]=coord[X]+1;
-			target2[X]=coord[X]+2;
-		} else {
-			target[X]=coord[X];	
-			target2[X]=coord[X];
-		}
-		if(dim==Y) {
-			if((coord[Y]+1)==DIM_SIZE[Y])
-				target[Y]=0;
-			else
-				target[Y]=coord[Y]+1;
-			if((coord[Y]-1)==-1)
-				target2[Y]=DIM_SIZE[Y]-1;
+			if((coord[dim]+1)>end[dim]) {
+				target[dim]=start[dim];
+			} else {
+				target[dim]=coord[dim]+1;
+			}
+			if((coord[dim]+2)>end[dim])
+				target2[dim]=end[dim];
 			else
-				target2[Y]=coord[Y]-1;
+				target2[dim]=coord[dim]+2;
 			
 		} else {
-			target[Y]=coord[Y];
-			target2[Y]=coord[Y];
-		}
-		if(dim==Z) {
-			if((coord[Z]+1)==DIM_SIZE[Z])
-				target[Z]=0;
+			if((coord[dim]+1)>end[dim])
+				target[dim]=start[dim];
 			else
-				target[Z]=coord[Z]+1;
-			if((coord[Z]-1)==-1)
-				target2[Z]=DIM_SIZE[Z]-1;
+				target[dim]=coord[dim]+1;
+			if((coord[dim]-1)<start[dim])
+				target2[dim]=end[dim];
 			else
-				target2[Z]=coord[Z]-1;
-		} else {
-			target[Z]=coord[Z];
-			target2[Z]=coord[Z];
+				target2[dim]=coord[dim]-1;
+			
 		}
+		
 		if(coord[dim]<(end[dim]-1)) {
 			/* set it up for 0 */
 			if(!curr_switch->int_wire[0].used) {
 				if(!_find_one_hop(curr_switch, 0, target, target2, dim)) {
 					_find_best_path(curr_switch, 0, target, target2, dim, 0);
 					_set_best_path();
-				} /* else {/\* the switch is full on this level, we can't use it *\/ */
-/* 					printf("Oh my gosh I can't do it in configure dims 0\n"); */
-/* 					printf("Switch %d%d%d dim %d\n",coord[X],coord[Y],coord[Z],dim); */
-/* 					for(j=0;j<6;j++) */
-/* 						printf("\t%d -> %d Used = %d\n", j, curr_switch->int_wire[j].port_tar, curr_switch->int_wire[j].used); */
-/* 					return 0; */
-/* 				} */
+				}
 			} 
 
 			if(!curr_switch->int_wire[1].used) { 
 				if(!_find_one_hop(curr_switch, 1, target, target2, dim)) {
 					_find_best_path(curr_switch, 1, target, target2, dim, 0);
 					_set_best_path();
-				} /* else {/\* the switch is full on this level, we can't use it *\/ */
-/* 					printf("Oh my gosh I can't do it in configure dims 1\n"); */
-/* 					printf("Switch %d%d%d dim %d\n",coord[X],coord[Y],coord[Z],dim); */
-/* 					for(j=0;j<6;j++) */
-/* 						printf("\t%d -> %d Used = %d\n", j, curr_switch->int_wire[j].port_tar, curr_switch->int_wire[j].used); */
-/* 					//return 0; */
-/* 				} */
+				} 
 			}
 			
 			/*****************************/
 			
 		} else if(coord[dim]==(end[dim]-1)) {
-			//next_switch = &pa_system_ptr->grid[coord[X]+1][coord[Y]][coord[Z]].axis_switch[X];	
+			if(dim == Y) {
+				printf("hey I am looking at %d%d%d as a target from %d%d%d\n",target[X],target[Y],target[Z],coord[X],coord[Y],coord[Z]);
+				
+			}
+			
 			if(!curr_switch->int_wire[0].used) {
 				_find_best_path(curr_switch, 0, target, target, dim, 0);
 				_set_best_path();
@@ -1458,8 +1461,8 @@ int main(int argc, char** argv)
 	pa_init(NULL);
 	results = list_create(NULL);
 	request->geometry[0] = 1;
-	request->geometry[1] = 4;
-	request->geometry[2] = 4;	
+	request->geometry[1] = 3;
+	request->geometry[2] = 1;	
 	request->size = -1; //atoi(argv[1]);
 	new_pa_request(request);
 	time(&start);
@@ -1524,13 +1527,13 @@ int main(int argc, char** argv)
 	int starty=0;
 	int startz=0;
 	int endx=0;
-	int endy=0;
-	int endz=4;
+	int endy=3;
+	int endz=0;
 	for(x=startx;x<=endx;x++) {
 		for(y=starty;y<=endy;y++) {
 			for(z=startz;z<=endz;z++) {
 				printf("Node %d%d%d Used = %d Letter = %c\n",x,y,z,pa_system_ptr->grid[x][y][z].used,pa_system_ptr->grid[x][y][z].letter);
-				for(dim=2;dim<3;dim++) {
+				for(dim=1;dim<2;dim++) {
 					printf("Dim %d\n",dim);
 					pa_switch_t *wire = &pa_system_ptr->grid[x][y][z].axis_switch[dim];
 					for(j=0;j<6;j++)
diff --git a/src/partition_allocator/partition_allocator.h b/src/partition_allocator/partition_allocator.h
index 51dda8923e33f2d69d6e0b5f1df33aa4c5ee3ca4..471fea1c8d240d9cedce3b127783905b77b68345 100644
--- a/src/partition_allocator/partition_allocator.h
+++ b/src/partition_allocator/partition_allocator.h
@@ -165,6 +165,7 @@ typedef struct {
 	pa_node_t ***grid;
 	pa_node_t *fill_in_value;
 } pa_system_t;
+
 /**
  * create a partition request.  Note that if the geometry is given,
  * then size is ignored.  If elongate is true, the algorithm will try
diff --git a/src/plugins/select/bluegene/bgl_job_place.c b/src/plugins/select/bluegene/bgl_job_place.c
index 921c2aab0459f046d72dfaff7a2018df965e4058..367c326e5c278ce82408088bd5a79cf3d9b457c4 100644
--- a/src/plugins/select/bluegene/bgl_job_place.c
+++ b/src/plugins/select/bluegene/bgl_job_place.c
@@ -33,43 +33,37 @@
 
 #define _DEBUG 0
 
-#define SWAP(a,b,t)	\
-_STMT_START {		\
-	(t) = (a);	\
-	(a) = (b);	\
-	(b) = (t);	\
-} _STMT_END
 
-static int  _find_best_partition_match(struct job_record* job_ptr,
+static int _rotate_geo(int *geometry);
+static bgl_record_t *_find_best_partition_match(struct job_record* job_ptr,
 				bitstr_t* slurm_part_bitmap,
 				int min_nodes, int max_nodes,
-				int spec, bgl_record_t** found_bgl_record);
-static void _rotate_geo(uint16_t *req_geometry, int rot_cnt);
+				int spec);
 
 /* Rotate a 3-D geometry array through its six permutations */
-static void _rotate_geo(uint16_t *req_geometry, int rot_cnt)
+static int _rotate_geo(int *geometry)
 {
-	uint16_t tmp;
-
-	switch (rot_cnt) {
-		case 0:		/* ABC -> ACB */
-			SWAP(req_geometry[1], req_geometry[2], tmp);
-			break;
-		case 1:		/* ACB -> CAB */
-			SWAP(req_geometry[0], req_geometry[1], tmp);
-			break;
-		case 2:		/* CAB -> CBA */
-			SWAP(req_geometry[1], req_geometry[2], tmp);
-			break;
-		case 3:		/* CBA -> BCA */
-			SWAP(req_geometry[0], req_geometry[1], tmp);
-			break;
-		case 4:		/* BCA -> BAC */
-			SWAP(req_geometry[1], req_geometry[2], tmp);
-			break;
-		case 5:		/* BAC -> ABC */
-			SWAP(req_geometry[0], req_geometry[1], tmp);
-			break;
+	static int rotate_count = 0;
+	int temp;
+
+	if (rotate_count==(PA_SYSTEM_DIMENSIONS-1)) {
+		//printf("Special!\n");
+		temp=geometry[X];
+		geometry[X]=geometry[Z];
+		geometry[Z]=temp;
+		rotate_count++;
+		return 1;
+		
+	} else if(rotate_count<(PA_SYSTEM_DIMENSIONS*2)) {
+		temp=geometry[X];
+		geometry[X]=geometry[Y];
+		geometry[Y]=geometry[Z];
+		geometry[Z]=temp;
+		rotate_count++;
+		return 1;
+	} else {
+		rotate_count = 0;
+		return 0;
 	}
 }
 /*
@@ -83,15 +77,15 @@ static void _rotate_geo(uint16_t *req_geometry, int rot_cnt)
  * returns 1 for error (no match)
  * 
  */
-static int _find_best_partition_match(struct job_record* job_ptr, 
+static bgl_record_t *_find_best_partition_match(struct job_record* job_ptr, 
 		bitstr_t* slurm_part_bitmap, int min_nodes, int max_nodes,
-		int spec, bgl_record_t** found_bgl_record)
+		int spec)
 {
 	ListIterator itr;
-	bgl_record_t* record;
+	bgl_record_t *record;
 	int i;
-	uint16_t req_geometry[SYSTEM_DIMENSIONS];
-	uint16_t conn_type, node_use, rotate, target_size = 1;
+	int req_geometry[SYSTEM_DIMENSIONS];
+	int conn_type, node_use, rotate, target_size = 1;
 
 	sort_bgl_record_inc_size(bgl_list);
 
@@ -111,125 +105,51 @@ static int _find_best_partition_match(struct job_record* job_ptr,
 	/* this is where we should have the control flow depending on
 	 * the spec arguement */
 	itr = list_iterator_create(bgl_list);
-	*found_bgl_record = NULL;
-
-	/*
-	 * FIXME: NEED TO PUT THIS LOGIC IN: 
-	 * if RM_NAV, then the partition with both the TORUS and the
-	 * dims should be favored over the MESH and the dims, but
-	 * foremost is the correct num of dims. 
-	 */
+	
 	debug("number of partitions to check: %d", list_count(bgl_list));
-	while ((record = (bgl_record_t*) list_next(itr))) {
+	while ((record = (bgl_record_t*) list_next(itr)) != NULL) {
 		/*
 		 * check that the number of nodes is suitable
 		 */
- 		if ((record->size < min_nodes)
-		||  (max_nodes != 0 && record->size > max_nodes)
-		||  (record->size < target_size)) {
-			debug("partition %s node count not suitable",
-				record->slurm_part_id);
-			continue;
-		}
-
-		/* Check that configured */
-		if (!record->alloc_part) {
-			error("warning, bgl_record %s undefined in "
-				"bluegene.conf", record->nodes);
-			continue;
-		}
-
-		/*
-		 * Next we check that this partition's bitmap is within 
-		 * the set of nodes which the job can use. 
-		 * Nodes not available for the job could be down,
-		 * drained, allocated to some other job, or in some 
-		 * SLURM partition not available to this job.
-		 */
-		if (!bit_super_set(record->bitmap, slurm_part_bitmap)) {
-			debug("bgl partition %s has nodes not usable by this "
-				"job", record->nodes);
-			continue;
-		}
-
-		/*
-		 * Insure that any required nodes are in this BGL partition
-		 */
-		if (job_ptr->details->req_node_bitmap
-		&& (!bit_super_set(job_ptr->details->req_node_bitmap,
-				record->bitmap))) {
-			info("bgl partition %s lacks required nodes",
-				record->nodes);
-			continue;
-		}
-
-		/***********************************************/
-		/* check the connection type specified matches */
-		/***********************************************/
-		if ((conn_type != record->conn_type)
-		&&  (conn_type != SELECT_NAV)) {
-			debug("bgl partition %s conn-type not usable", 
-				record->nodes);
-			continue;
-		} 
-
-		/***********************************************/
-		/* check the node_use specified matches        */
-		/***********************************************/
-		if ((node_use != record->node_use) 
-		&&  (node_use != SELECT_NAV)) {
-			debug("bgl partition %s node-use not usable", 
-					record->nodes);
-			continue;
-		}
-
-		/*****************************************/
-		/* match up geometry as "best" possible  */
-		/*****************************************/
-		if (req_geometry[0] == 0)
-			;	/* Geometry not specified */
-		else {	/* match requested geometry */
-			bool match = false;
-			int rot_cnt = 0;	/* attempt six rotations  */
-
-			for (rot_cnt=0; rot_cnt<6; rot_cnt++) {
-				for (i=0; i<SYSTEM_DIMENSIONS; i++) {
-					if (record->alloc_part->dimensions[i] <
-							req_geometry[i])
+ 		if ((record->state == RM_PARTITION_FREE)  
+		      && ((conn_type == record->conn_type)
+			|| (conn_type != SELECT_NAV))
+		    && ((node_use == record->node_use) 
+			|| (node_use != SELECT_NAV))
+		    && (record->bp_count > min_nodes)
+		    && (record->bp_count < max_nodes)
+		    && (record->bp_count < target_size) 
+			) {
+		
+			/*****************************************/
+			/* match up geometry as "best" possible  */
+			/*****************************************/
+			if (req_geometry[0]) {				
+				/* match requested geometry */
+				
+				while(1) {
+					if ((record->coord[X] == req_geometry[X])
+					    && (record->coord[Y] == req_geometry[Y])
+					    && (record->coord[Z] == req_geometry[Z]))
+						break;
+					else if(!_rotate_geo(req_geometry))
 						break;
 				}
-				if (i == SYSTEM_DIMENSIONS) {
-					match = true;
-					break;
-				}
-				if (rotate == 0)
-					break;		/* not usable */
-				_rotate_geo(req_geometry, rot_cnt);
-			}
-
-			if (!match) 
-				continue;	/* Not usable */
-		}
-
-		if ((*found_bgl_record == NULL)
-		||  (record->size < (*found_bgl_record)->size)) {
-			*found_bgl_record = record;
-			if (record->size == target_size)
+				
+			} else if (record->bp_count == target_size)
 				break;
+			
+		}
+		
+		/* set the bitmap and do other allocation activities */
+		if (record) {
+			
+			return record;
 		}
-	}	
-	
-	/* set the bitmap and do other allocation activities */
-	if (*found_bgl_record) {
-		debug("_find_best_partition_match %s <%s>", 
-			(*found_bgl_record)->slurm_part_id, 
-			(*found_bgl_record)->nodes);
-		bit_and(slurm_part_bitmap, (*found_bgl_record)->bitmap);
-		return SLURM_SUCCESS;
 	}
 	
 	debug("_find_best_partition_match none found");
-	return SLURM_ERROR;
+	return NULL;
 }
 
 /*
@@ -252,20 +172,24 @@ extern int submit_job(struct job_record *job_ptr, bitstr_t *slurm_part_bitmap,
 		SELECT_PRINT_MIXED);
 	debug("bluegene:submit_job: %s nodes=%d-%d", buf, min_nodes, max_nodes);
 	
-	if (_find_best_partition_match(job_ptr, slurm_part_bitmap, min_nodes, 
-					max_nodes, spec, &record)) {
+	if((record = _find_best_partition_match(job_ptr, 
+						slurm_part_bitmap, 
+						min_nodes, 
+						max_nodes, 
+						spec)) == NULL) {
 		return SLURM_ERROR;
 	} else {
 		/* now we place the part_id into the env of the script to run */
-		char bgl_part_id[BITSIZE];
+		
 #ifdef HAVE_BGL_FILES
-		snprintf(bgl_part_id, BITSIZE, "%s", record->bgl_part_id);
+		select_g_set_jobinfo(job_ptr->select_jobinfo,
+				     SELECT_DATA_PART_ID, record->bgl_part_id);
 #else
-		snprintf(bgl_part_id, BITSIZE, "UNDEFINED");
-#endif
 		select_g_set_jobinfo(job_ptr->select_jobinfo,
-			SELECT_DATA_PART_ID, bgl_part_id);
+				     SELECT_DATA_PART_ID, "UNDEFINED");
+#endif
+		
 	}
-
+	
 	return SLURM_SUCCESS;
 }
diff --git a/src/plugins/select/bluegene/bgl_switch_connections.c b/src/plugins/select/bluegene/bgl_switch_connections.c
index 3c249f6430772754b58fda6ba55716feac320e96..55c9312106097e85b2ce2b0b30b66e4e0b2de158 100644
--- a/src/plugins/select/bluegene/bgl_switch_connections.c
+++ b/src/plugins/select/bluegene/bgl_switch_connections.c
@@ -28,14 +28,18 @@
 
 #ifdef HAVE_BGL_FILES
 
-static int _get_bp_by_location(rm_BGL_t* my_bgl, int* cur_coord, rm_BP_t** bp);
-static int _set_switch(rm_switch_t* cur_switch, pa_connection_t *int_wire);
+List bgl_bp_list;
+
+static int _get_bp_by_location(rm_BGL_t* my_bgl, int* curr_coord, rm_BP_t** bp);
+static int _set_switch(rm_switch_t* curr_switch, pa_connection_t *int_wire);
+static int _add_switch_conns(rm_switch_t* curr_switch, bgl_switch_t *bgl_switch);
+static int _lookat_path(bgl_bp_t *bgl_bp, pa_switch_t *curr_switch, int source, int target, int dim);
 
 /** 
  * this is just stupid.  there are some implicit rules for where
  * "NextBP" goes to, but we don't know, so we have to do this.
  */
-static int _get_bp_by_location(rm_BGL_t* my_bgl, int* cur_coord, rm_BP_t** bp)
+static int _get_bp_by_location(rm_BGL_t* my_bgl, int* curr_coord, rm_BP_t** bp)
 {
 	int i, bp_num;
 	rm_location_t loc;
@@ -45,10 +49,10 @@ static int _get_bp_by_location(rm_BGL_t* my_bgl, int* cur_coord, rm_BP_t** bp)
 
 	for (i=0; i<bp_num; i++){
 		rm_get_data(*bp, RM_BPLoc, &loc);
-		//printf("%d%d%d %d%d%d\n",loc.X,loc.Y,loc.Z,cur_coord[X],cur_coord[Y],cur_coord[Z]); 
-		if ((loc.X == cur_coord[X])
-		&&  (loc.Y == cur_coord[Y])
-		&&  (loc.Z == cur_coord[Z])) {
+		//printf("%d%d%d %d%d%d\n",loc.X,loc.Y,loc.Z,curr_coord[X],curr_coord[Y],curr_coord[Z]); 
+		if ((loc.X == curr_coord[X])
+		&&  (loc.Y == curr_coord[Y])
+		&&  (loc.Z == curr_coord[Z])) {
 			return 1;
 		}
 		rm_get_data(my_bgl, RM_NextBP, bp);
@@ -58,7 +62,7 @@ static int _get_bp_by_location(rm_BGL_t* my_bgl, int* cur_coord, rm_BP_t** bp)
 	return 0;
 }
 
-static int _set_switch(rm_switch_t* cur_switch, pa_connection_t *int_wire)
+static int _set_switch(rm_switch_t* curr_switch, pa_connection_t *int_wire)
 {
 	int firstconnect=1;
 	rm_connection_t conn;
@@ -92,97 +96,355 @@ static int _set_switch(rm_switch_t* cur_switch, pa_connection_t *int_wire)
 				break;
 			}
 			conn.part_state = RM_PARTITION_READY;
-			//printf("Connecting %d - %d\n",j,int_wire[j].port_tar);
+			//printf("Connecting %d - %d\n",(conn.p1-6),(conn.p2-6));
 			if(firstconnect) {
-				rm_set_data(cur_switch,RM_SwitchFirstConnection, &conn);
+				rm_set_data(curr_switch,RM_SwitchFirstConnection, &conn);
 				firstconnect=0;
 			} else 
-				rm_set_data(cur_switch,RM_SwitchNextConnection, &conn);   
+				rm_set_data(curr_switch,RM_SwitchNextConnection, &conn);   
 			conn_num++;
 		}		
 	}
 	//printf("conn_num = %d\n",conn_num);
-	rm_set_data(cur_switch, RM_SwitchConnNum, &conn_num);
+	rm_set_data(curr_switch, RM_SwitchConnNum, &conn_num);
 	return 1;
 }
 
+static int _add_switch_conns(rm_switch_t* curr_switch, bgl_switch_t *bgl_switch)
+{
+	ListIterator itr;
+	bgl_conn_t *bgl_conn;
+	
+	int firstconnect=1;
+	rm_connection_t conn;
+	int j;
+	int conn_num=0;
+	int port;
+	
+	itr = list_iterator_create(bgl_switch->conn_list);
+	while((bgl_conn = list_next(itr)) != NULL) {
+		for(j=0;j<2;j++) {
+			switch(j) {
+			case 0:
+				port = bgl_conn->source;
+				break;
+			case 1:
+				port = bgl_conn->target;
+				break;
+			}
+			switch(port) {
+			case 0:
+				conn.p2 = RM_PORT_S0; 
+				break;
+			case 1:
+				conn.p1 = RM_PORT_S1;
+				break;
+			case 2:
+				conn.p1 = RM_PORT_S2;
+				break;
+			case 3:
+				conn.p2 = RM_PORT_S3; 
+				break;
+			case 4:
+				conn.p1 = RM_PORT_S4;
+				break;
+			case 5:
+				conn.p2 = RM_PORT_S5; 
+				break;
+			}
+		}
+		conn.part_state = RM_PARTITION_READY;
+		//printf("Connecting %d - %d\n",bgl_conn->source,bgl_conn->target);
+		//printf("Connecting %d - %d\n",(conn.p1-6),(conn.p2-6));
+			
+		if(firstconnect) {
+			rm_set_data(curr_switch, RM_SwitchFirstConnection, &conn);
+			firstconnect=0;
+		} else 
+			rm_set_data(curr_switch, RM_SwitchNextConnection, &conn);   
+		conn_num++;
+		
+	}
+	list_iterator_destroy(itr);
+		
+	//printf("conn_num = %d\n",conn_num);
+	rm_set_data(curr_switch, RM_SwitchConnNum, &conn_num);
+	return 1;
+}
+
+static int _lookat_path(bgl_bp_t *bgl_bp, pa_switch_t *curr_switch, int source, int target, int dim) 
+{
+	ListIterator bgl_itr, switch_itr, conn_itr;
+	bgl_switch_t *bgl_switch;
+	bgl_conn_t *bgl_conn;
+	int *node_tar;
+	int port_tar;
+	int port_tar1;
+	int *node_src;
+	pa_switch_t *next_switch; 
+	
+	switch_itr = list_iterator_create(bgl_bp->switch_list);
+	while((bgl_switch = list_next(switch_itr)) != NULL) {
+		if(bgl_switch->dim == dim)
+			break;
+	}
+	list_iterator_destroy(switch_itr);
+	
+	if(bgl_switch == NULL) {
+		bgl_switch = xmalloc(sizeof(bgl_switch_t));
+		bgl_switch->dim=dim;
+		bgl_switch->conn_list = list_create(NULL);
+		list_append(bgl_bp->switch_list, bgl_switch);
+	}
+		
+	port_tar = curr_switch->int_wire[source].port_tar;
+	
+	conn_itr = list_iterator_create(bgl_switch->conn_list);
+	//printf("looking at dim %d conn %d -> %d\n", dim, source, port_tar);
+	while((bgl_conn = list_next(conn_itr)) != NULL) {
+		if(((bgl_conn->source == port_tar)
+		    && (bgl_conn->target == source))
+		   || ((bgl_conn->source == source)
+		   && (bgl_conn->target == port_tar)))
+			break;
+	}
+	list_iterator_destroy(conn_itr);
+	
+	if(bgl_conn == NULL) {
+		bgl_conn = xmalloc(sizeof(bgl_conn));
+		bgl_conn->source = source;
+		bgl_conn->target = port_tar;
+		//printf("adding to dim %d conn %d -> %d\n\n", dim, source, port_tar);
+		list_append(bgl_switch->conn_list, bgl_conn);
+	} else {
+		//printf("I found a match returning\n\n");
+		return 1;	
+	}
+	if(port_tar==target) {
+		//printf("I found the target\n\n");
+		
+		return 1;
+	}
+	port_tar1 = port_tar;
+	port_tar = curr_switch->ext_wire[port_tar].port_tar;
+	node_tar = curr_switch->ext_wire[port_tar].node_tar;
+	node_src = curr_switch->ext_wire[0].node_tar;
+
+	bgl_itr = list_iterator_create(bgl_bp_list);
+	while((bgl_bp = list_next(bgl_itr)) != NULL) {
+		if((bgl_bp->coord[X] == node_tar[X]) 
+		   && (bgl_bp->coord[Y] == node_tar[Y]) 
+		   && (bgl_bp->coord[Z] == node_tar[Z]))
+			break;
+	}
+	list_iterator_destroy(bgl_itr);
+	if(bgl_bp == NULL) {
+		bgl_bp = xmalloc(sizeof(bgl_bp_t));
+		bgl_bp->coord = node_tar;
+		bgl_bp->switch_list = list_create(NULL);
+		list_append(bgl_bp_list, bgl_bp);
+		bgl_bp->used = 0;
+	}
+	
+	//printf("going from %d%d%d port %d -> %d %d%d%d %d\n",node_src[X], node_src[Y], node_src[Z], source, port_tar1, node_tar[X], node_tar[Y], node_tar[Z], port_tar);
+	next_switch = &pa_system_ptr->
+		grid[node_tar[X]][node_tar[Y]][node_tar[Z]].axis_switch[dim];
+	//printf("sending %d -> %d\n",port_tar,next_switch->int_wire[port_tar].port_tar);
+	_lookat_path(bgl_bp, next_switch, port_tar, target, dim);	
+	
+	return 1;
+}
 /**
  * connect the given switch up with the given connections
  */
-int configure_partition_switches(bgl_conf_record_t * bgl_conf_record)
+int configure_partition_switches(bgl_record_t * bgl_record)
 {
-	int  i, j;
-	ListIterator itr;
+	int i;
+	ListIterator itr, switch_itr, bgl_itr;
 	pa_node_t* pa_node;
-	rm_BP_t *cur_bp;
-	rm_switch_t *cur_switch;
-	//char *name2;
-	char *bpid, *cur_bpid;
-	int switchnum = bgl_conf_record->size*3;
+	char *name2;
+	rm_BP_t *curr_bp;
+	rm_switch_t *coord_switch[PA_SYSTEM_DIMENSIONS];
+	pa_switch_t *pa_switch;
+	char *bpid, *curr_bpid;
 	int found_bpid = 0;
 	int switch_count;
 	rm_location_t loc;
-	rm_set_data(bgl_conf_record->bgl_part,RM_PartitionSwitchNum,&switchnum); 
-	rm_set_data(bgl_conf_record->bgl_part,RM_PartitionBPNum,&bgl_conf_record->size); 
+	bgl_bp_t *bgl_bp;
+	bgl_switch_t *bgl_switch;
+	int first_bp=1;
+	int first_switch=1;
+	bgl_bp_list = list_create(NULL);
+	bgl_record->switch_count = 0;
+	bgl_record->bp_count = 0;
 		
-	itr = list_iterator_create(bgl_conf_record->bgl_part_list);
-	i=0;
+	itr = list_iterator_create(bgl_record->bgl_part_list);
 	while ((pa_node = (pa_node_t *) list_next(itr)) != NULL) {
 		//printf("Looking for %d%d%d\n",pa_node->coord[X],pa_node->coord[Y],pa_node->coord[Z]); 
-		
-		if (!_get_bp_by_location(bgl, pa_node->coord, &cur_bp)) {
-			return 0;
+		bgl_itr = list_iterator_create(bgl_bp_list);
+		while((bgl_bp = list_next(bgl_itr)) != NULL) {
+			if((bgl_bp->coord[X] == pa_node->coord[X])
+			   && (bgl_bp->coord[Y] == pa_node->coord[Y])
+			   && (bgl_bp->coord[Z] == pa_node->coord[Z]))
+				break;
+		}
+		list_iterator_destroy(bgl_itr);
+
+		if(bgl_bp == NULL) {
+			bgl_bp = xmalloc(sizeof(bgl_bp_t));
+			bgl_bp->coord = pa_node->coord;
+			bgl_bp->switch_list = list_create(NULL);
+			list_append(bgl_bp_list, bgl_bp);
+		}
+		bgl_bp->used = 1;
+		for(i=0;i<PA_SYSTEM_DIMENSIONS;i++) {
+			
+			pa_switch = &pa_node->axis_switch[i];
+			if(pa_switch->int_wire[0].used) {
+				_lookat_path(bgl_bp, pa_switch, 0, 1, i);
+			}
+			
+			if(pa_switch->int_wire[1].used) {
+				_lookat_path(bgl_bp, pa_switch, 1, 0, i);
+			}
 		}
-		rm_get_data(cur_bp, RM_BPLoc, &loc);
-		//printf("found %d%d%d %d%d%d\n",loc.X,loc.Y,loc.Z,pa_node->coord[X],pa_node->coord[Y],pa_node->coord[Z]); 
-		if (!i){
-			rm_set_data(bgl_conf_record->bgl_part, RM_PartitionFirstBP, cur_bp);
-		} else {
-			rm_set_data(bgl_conf_record->bgl_part, RM_PartitionNextBP, cur_bp);
+	}
+	list_iterator_destroy(itr);
+	
+	bgl_itr = list_iterator_create(bgl_bp_list);
+	while((bgl_bp = list_next(bgl_itr)) != NULL) {
+		bgl_record->bp_count++;
+		itr = list_iterator_create(bgl_bp->switch_list);
+		while((bgl_switch = list_next(itr)) != NULL) {
+			bgl_record->switch_count++;
+		}
+		list_iterator_destroy(itr);
+	}
+	list_iterator_destroy(bgl_itr);
+	rm_set_data(bgl_record->bgl_part,RM_PartitionBPNum,&bgl_record->bp_count);
+	rm_set_data(bgl_record->bgl_part,RM_PartitionSwitchNum,&bgl_record->switch_count);
+	/* printf("BP_count = %d\n",bgl_record->bp_count); */
+/* 	printf("switch_count = %d\n",bgl_record->switch_count); */
+	bgl_itr = list_iterator_create(bgl_bp_list);
+	
+	first_bp = 1;
+	first_switch = 1;
+	while((bgl_bp = list_next(bgl_itr)) != NULL) {
+			
+		if (!_get_bp_by_location(bgl, bgl_bp->coord, &curr_bp)) {
+			return 0;
 		}
-		rm_get_data(cur_bp,RM_BPID,&bpid);
-		//printf("bp name = %s\n",(char *)bpid);
+		rm_get_data(curr_bp, RM_BPLoc, &loc);
+		//printf("found %d%d%d %d%d%d\n",loc.X,loc.Y,loc.Z,pa_node->coord[X],pa_node->coord[Y],pa_node->coord[Z]);
+		//if(bgl_bp->used) {
+			if (first_bp){
+				rm_set_data(bgl_record->bgl_part, RM_PartitionFirstBP, curr_bp);
+				first_bp = 0;
+			} else {
+				rm_set_data(bgl_record->bgl_part, RM_PartitionNextBP, curr_bp);
+			}
+			//}
+		rm_get_data(curr_bp, RM_BPID, &bpid);
+		/* printf("bp name = %s\n",(char *)bpid); */
 		
 		rm_get_data(bgl, RM_SwitchNum, &switch_count);
-		rm_get_data(bgl, RM_FirstSwitch,&cur_switch);
+		rm_get_data(bgl, RM_FirstSwitch,&coord_switch[X]);
 		found_bpid = 0;
 		for (i=0; i<switch_count; i++) {
-			rm_get_data(cur_switch, RM_SwitchBPID, &cur_bpid);
-			//printf("Bpid = %s, cur_bpid = %s\n",(char *)bpid, (char *)cur_bpid);
-			if (!strcasecmp((char *)bpid, (char *)cur_bpid)) {
+			rm_get_data(coord_switch[X], RM_SwitchBPID, &curr_bpid);
+			//printf("Bpid = %s, curr_bpid = %s\n",(char *)bpid, (char *)curr_bpid);
+			if (!strcasecmp((char *)bpid, (char *)curr_bpid)) {
 				found_bpid = 1;
 				break;
 			}
 			
-			rm_get_data(bgl,RM_NextSwitch,&cur_switch);
+			rm_get_data(bgl,RM_NextSwitch,&coord_switch[X]);
 		}
-		if(found_bpid) {
 	
-			for(j=0;j<PA_SYSTEM_DIMENSIONS;j++) {
-				//rm_get_data(cur_switch,RM_SwitchID,&name2);
-				//printf("dim %d\n",j);
-				if(j!=X) {
-					pa_node->axis_switch[j].int_wire[3].used = 0;
-					pa_node->axis_switch[j].int_wire[4].used = 0;
-				}
-				_set_switch(cur_switch, pa_node->axis_switch[j].int_wire);		
+		if(found_bpid) {
+			rm_get_data(bgl,RM_NextSwitch,&coord_switch[Y]);
+			rm_get_data(bgl,RM_NextSwitch,&coord_switch[Z]);
+					
+			switch_itr = list_iterator_create(bgl_bp->switch_list);
+			while((bgl_switch = list_next(switch_itr)) != NULL) {
+				rm_get_data(coord_switch[bgl_switch->dim],RM_SwitchID,&name2);
+				/* printf("dim %d name %s\n", bgl_switch->dim, name2); */
 				
-				if (!i){
-					rm_set_data(bgl_conf_record->bgl_part, RM_PartitionFirstSwitch, cur_switch);
+				_add_switch_conns(coord_switch[bgl_switch->dim], bgl_switch);
+				
+				if (first_switch){
+					rm_set_data(bgl_record->bgl_part,
+						    RM_PartitionFirstSwitch,
+						    coord_switch[bgl_switch->dim]);
+					first_switch = 0;
 				} else {
-					rm_set_data(bgl_conf_record->bgl_part, RM_PartitionNextSwitch, cur_switch);
-				}
-				if(j!=X) {
-					pa_node->axis_switch[j].int_wire[3].used = 1;
-					pa_node->axis_switch[j].int_wire[4].used = 1;
+					rm_set_data(bgl_record->bgl_part,
+						    RM_PartitionNextSwitch,
+						    coord_switch[bgl_switch->dim]);
 				}
-				i++;
-				rm_get_data(bgl,RM_NextSwitch,&cur_switch);
-				//rm_free_switch(cur_switch);
 			}
 		}
 	}
+	list_destroy(bgl_bp_list);
+/* 		rm_switch_t *curr_switch; */
+/* 		int j; */
+/* 	bgl_record->bp_count = 4; */
+/* 		bgl_record->switch_count = 12; */
+/* 	rm_set_data(bgl_record->bgl_part,RM_PartitionBPNum,&bgl_record->bp_count); */
+/* 	rm_set_data(bgl_record->bgl_part,RM_PartitionSwitchNum,&bgl_record->switch_count); */
+/*  	while ((pa_node = (pa_node_t *) list_next(itr)) != NULL) { */
+/* 		if (!_get_bp_by_location(bgl, pa_node->coord, &curr_bp)) { */
+/* 			return 0; */
+/* 		} */
+/* 		rm_get_data(curr_bp, RM_BPLoc, &loc); */
+/* 		//printf("found %d%d%d %d%d%d\n",loc.X,loc.Y,loc.Z,pa_node->coord[X],pa_node->coord[Y],pa_node->coord[Z]); */
+/* 		if (!i){ */
+/* 			rm_set_data(bgl_record->bgl_part, RM_PartitionFirstBP, curr_bp); */
+/* 		} else { */
+/* 			rm_set_data(bgl_record->bgl_part, RM_PartitionNextBP, curr_bp); */
+/* 		} */
+/* 		rm_get_data(curr_bp,RM_BPID,&bpid); */
+/* 		//printf("bp name = %s\n",(char *)bpid); */
+		
+/* 		rm_get_data(bgl, RM_SwitchNum, &switch_count); */
+/* 		rm_get_data(bgl, RM_FirstSwitch,&curr_switch); */
+/* 		found_bpid = 0; */
+/* 		for (i=0; i<switch_count; i++) { */
+/* 			rm_get_data(curr_switch, RM_SwitchBPID, &curr_bpid); */
+/* 			//printf("Bpid = %s, curr_bpid = %s\n",(char *)bpid, (char *)curr_bpid); */
+/* 			if (!strcasecmp((char *)bpid, (char *)curr_bpid)) { */
+/* 				found_bpid = 1; */
+/* 				break; */
+/* 			} */
+			
+/* 			rm_get_data(bgl,RM_NextSwitch,&curr_switch); */
+/* 		} */
+/* 		if(found_bpid) { */
 	
+/* 			for(j=0;j<PA_SYSTEM_DIMENSIONS;j++) { */
+/* 				//rm_get_data(curr_switch,RM_SwitchID,&name2); */
+/* 				//printf("dim %d\n",j); */
+/* 				if(j!=X) { */
+/* 					pa_node->axis_switch[j].int_wire[3].used = 0; */
+/* 					pa_node->axis_switch[j].int_wire[4].used = 0; */
+/* 				} */
+/* 				_set_switch(curr_switch, pa_node->axis_switch[j].int_wire); */
+				
+/* 				if (!i){ */
+/* 					rm_set_data(bgl_record->bgl_part, RM_PartitionFirstSwitch, curr_switch); */
+/* 				} else { */
+/* 					rm_set_data(bgl_record->bgl_part, RM_PartitionNextSwitch, curr_switch); */
+/* 				} */
+/* 				if(j!=X) { */
+/* 					pa_node->axis_switch[j].int_wire[3].used = 1; */
+/* 					pa_node->axis_switch[j].int_wire[4].used = 1; */
+/* 				} */
+/* 				i++; */
+/* 				rm_get_data(bgl,RM_NextSwitch,&curr_switch); */
+/* 				//rm_free_switch(curr_switch); */
+/* 			} */
+/* 		} */
+/* 	} */
 	//printf("done with switches\n");
 	return 1;	
 }
diff --git a/src/plugins/select/bluegene/bluegene.c b/src/plugins/select/bluegene/bluegene.c
index c07e64d96f142226ac238ed3331f4f43409f2b24..c0b58b01c631d1c88ec04a4992eb70a0e593cdf9 100644
--- a/src/plugins/select/bluegene/bluegene.c
+++ b/src/plugins/select/bluegene/bluegene.c
@@ -33,7 +33,6 @@
 #define _DEBUG 0
 
 char* bgl_conf = BLUEGENE_CONFIG_FILE;
-List bgl_conf_list = NULL;              /* list of bgl_conf_record entries */
 
 /* Global variables */
 rm_BGL_t *bgl;
@@ -46,14 +45,13 @@ bool agent_fini = false;
 static int  _bgl_record_cmpf_inc(bgl_record_t* rec_a, bgl_record_t* rec_b);
 /* static int  _bgl_record_cmpf_dec(bgl_record_t* rec_a, bgl_record_t* rec_b); */
 static int  _copy_slurm_partition_list(List slurm_part_list);
-static void _destroy_bgl_conf_record(void* object);
 static void _destroy_bgl_record(void* object);
 //static void _diff_tv_str(struct timeval *tv1,struct timeval *tv2, char *tv_str, int len_tv_str);
-static bgl_conf_record_t* _find_config_by_nodes(char* nodes);
-static int  _listfindf_conf_part_record(bgl_conf_record_t* record, char *nodes);
+static bgl_record_t* _find_config_by_nodes(char* nodes);
+static int  _listfindf_part_record(bgl_record_t* record, char *nodes);
 static int  _parse_bgl_spec(char *in_line);
-static int  _parse_request(char* request_string, partition_t** request);
-static void _process_config(void);
+//static int  _parse_request(char* request_string, partition_t** request);
+//static void _process_config(void);
 //static int  _sync_partitions(void);
 static int  _validate_config_nodes(void);
 
@@ -76,10 +74,10 @@ int create_static_partitions(List part_list)
 	int x, y, z;
 	int start[PA_SYSTEM_DIMENSIONS];
 	int end[PA_SYSTEM_DIMENSIONS];
-	bgl_conf_record_t *bgl_conf_record;
+	bgl_record_t *bgl_record;
 	rm_partition_state_t state;
         
-	pm_partition_id_t part_id[10];
+	pm_partition_id_t part_id[20];
 	rm_partition_t *my_part;
 	int i;
 	rm_BP_t * bp;
@@ -97,10 +95,9 @@ int create_static_partitions(List part_list)
 	   this means we are blowing the partitions away right at the beginning
 	   no matter what */
 
-/* 	if (bgl_list) { */
-/* 		bgl_record_t *record; */
-/* 		while ((record = list_pop(bgl_list))) */
-/* 			_destroy_bgl_record(record); */
+	/* if (bgl_list) { */
+/* 		while ((bgl_record = list_pop(bgl_list))) */
+/* 			_destroy_bgl_record(bgl_record); */
 /* 	} else */
 /* 		bgl_list = list_create(_destroy_bgl_record); */
 /* 	printf("copying\n"); */
@@ -123,103 +120,115 @@ int create_static_partitions(List part_list)
 	part_id[3]="RMP104";
 	part_id[4]="RMP105";
 	part_id[5]="RMP106";
-	bp_num=6;
+	part_id[6]="RMP107";
+	part_id[7]="RMP108";
+	part_id[8]="RMP109";
+	part_id[9]="RMP110";
+	part_id[10]="RMP111";
+	part_id[11]="RMP112";
+	part_id[12]="RMP113";
+	part_id[13]="RMP114";
+	part_id[14]="RMP115";
+	part_id[15]="RMP116";
+	part_id[16]="RMP117";
+	part_id[17]="RMP118";
+	part_id[18]="RMP119";
+	part_id[19]="RMP120";
+	bp_num=1;
 	//rm_get_data(bgl, RM_BPNum, &bp_num);
 	//rm_get_data(bgl, RM_FirstBP, &bp);
 	for (i=0; i<bp_num; i++){
 		//	rm_get_data(bp, RM_BPPartID, &part_id);
 		if ((rc = rm_get_partition(part_id[i], &my_part))
 		    != STATUS_OK) {
-					
 		} else {
-
-		rm_get_data(my_part, RM_PartitionUserName, &name);
-		//printf("user name for %s is %s\n",part_id[i],name);
-		//if(!strcmp(name,"")) {
-		printf("destroying %s\n",(char *)part_id[i]);
-		rm_get_data(my_part, RM_PartitionState, &state);
-		if(state != RM_PARTITION_FREE)
-			pm_destroy_partition(part_id[i]);
-		
-		rm_get_data(my_part, RM_PartitionState, &state);
-		while ((state != RM_PARTITION_FREE)
-		&&     (state != RM_PARTITION_ERROR)) {
-			printf(".");
-			rc=rm_free_partition(my_part);
-			if(rc!=STATUS_OK){
-				printf("Error freeing partition\n");
-				return(-1);
-			}
-			sleep(3);
-			rc=rm_get_partition(part_id[i],&my_part);
-			if(rc!=STATUS_OK){
-				printf("Error in GetPartition\n");
-				return(-1);
-			}
+			
+			rm_get_data(my_part, RM_PartitionUserName, &name);
+			//printf("user name for %s is %s\n",part_id[i],name);
+			//if(!strcmp(name,"")) {
+			printf("destroying %s\n",(char *)part_id[i]);
 			rm_get_data(my_part, RM_PartitionState, &state);
-			//Free memory allocated to mypart
+			if(state != RM_PARTITION_FREE)
+				pm_destroy_partition(part_id[i]);
 			
-		}
-		rm_remove_partition(part_id[i]);
-		sleep(3);
-		printf("done\n");
-		//}
-		//rm_get_data(bgl, RM_NextBP, &bp);
+			rm_get_data(my_part, RM_PartitionState, &state);
+			while ((state != RM_PARTITION_FREE) 
+			       && (state != RM_PARTITION_ERROR)){
+				printf(".");
+				rc=rm_free_partition(my_part);
+				if(rc!=STATUS_OK){
+					printf("Error freeing partition\n");
+					return(-1);
+				}
+				sleep(3);
+				rc=rm_get_partition(part_id[i],&my_part);
+				if(rc!=STATUS_OK) {
+					printf("Error in GetPartition\n");
+					return(-1);
+				}
+				rm_get_data(my_part, RM_PartitionState, &state);
+				//Free memory allocated to mypart
+			}
+			rm_remove_partition(part_id[i]);
+			sleep(3);
+			printf("done\n");
+			//}
+			//rm_get_data(bgl, RM_NextBP, &bp);
 		}	
 	}
 	
-	itr = list_iterator_create(bgl_conf_list);
-		while ((bgl_conf_record = (bgl_conf_record_t *) list_next(itr)) != NULL) {
-			j=0;
-			while (bgl_conf_record->nodes[j] != '\0') {
-				if ((bgl_conf_record->nodes[j]   == '[')
-				    &&  (bgl_conf_record->nodes[j+4] == 'x')
-				    &&  (bgl_conf_record->nodes[j+8] == ']')) {
-					j++;
-					number = atoi(bgl_conf_record->nodes + j);
-					start[X] = number / 100;
-					start[Y] = (number % 100) / 10;
-					start[Z] = (number % 10);
-					j += 4;
-					number = atoi(bgl_conf_record->nodes + j);
-					end[X] = number / 100;
-					end[Y] = (number % 100) / 10;
-					end[Z] = (number % 10);
-					j += 5;
-				}
+	itr = list_iterator_create(bgl_list);
+	while ((bgl_record = (bgl_record_t *) list_next(itr)) != NULL) {
+		j=0;
+		while (bgl_record->nodes[j] != '\0') {
+			if ((bgl_record->nodes[j]   == '[')
+			    &&  (bgl_record->nodes[j+4] == 'x')
+			    &&  (bgl_record->nodes[j+8] == ']')) {
 				j++;
+				number = atoi(bgl_record->nodes + j);
+				start[X] = number / 100;
+				start[Y] = (number % 100) / 10;
+				start[Z] = (number % 10);
+				j += 4;
+				number = atoi(bgl_record->nodes + j);
+				end[X] = number / 100;
+				end[Y] = (number % 100) / 10;
+				end[Z] = (number % 10);
+				j += 5;
 			}
-			assert(end[X] < DIM_SIZE[X]);
-			assert(start[X] >= 0);
-			assert(end[Y] < DIM_SIZE[Y]);
-			assert(start[Y] >= 0);
-			assert(end[Z] < DIM_SIZE[Z]);
-			assert(start[Z] >= 0);
-			bgl_conf_record->bgl_part_list = list_create(NULL);
-			j=0;
-			/* printf("creating list %d%d%dx%d%d%d\n", */
-/* 			       start[X],start[Y],start[Z],end[X],end[Y],end[Z]); */
-			for (x = start[X]; x <= end[X]; x++)
-				for (y = start[Y]; y <= end[Y]; y++)
-					for (z = start[Z]; z <= end[Z]; z++) {
-						list_append(bgl_conf_record->bgl_part_list, 
-							    &pa_system_ptr->grid[x][y][z]);
-						j++;
-					}
-			bgl_conf_record->size = j;
-			set_bgl_part(bgl_conf_record->bgl_part_list, 
-				     bgl_conf_record->size, 
-				     bgl_conf_record->conn_type);			
-			
+			j++;
 		}
-		list_iterator_destroy(itr);
+		assert(end[X] < DIM_SIZE[X]);
+		assert(start[X] >= 0);
+		assert(end[Y] < DIM_SIZE[Y]);
+		assert(start[Y] >= 0);
+		assert(end[Z] < DIM_SIZE[Z]);
+		assert(start[Z] >= 0);
+		bgl_record->bgl_part_list = list_create(NULL);
+		j=0;
+		/* printf("creating list %d%d%dx%d%d%d\n", */
+/* 			       start[X],start[Y],start[Z],end[X],end[Y],end[Z]); */
+		for (x = start[X]; x <= end[X]; x++)
+			for (y = start[Y]; y <= end[Y]; y++)
+				for (z = start[Z]; z <= end[Z]; z++) {
+					list_append(bgl_record->bgl_part_list, 
+						    &pa_system_ptr->grid[x][y][z]);
+					j++;
+				}
+		bgl_record->bp_count = j;
+		set_bgl_part(bgl_record->bgl_part_list, 
+			     bgl_record->bp_count, 
+			     bgl_record->conn_type);			
 		
-		itr = list_iterator_create(bgl_conf_list);
-		while ((bgl_conf_record = (bgl_conf_record_t *) list_next(itr)) != NULL)			
-			configure_partition(bgl_conf_record);
-				
-		list_iterator_destroy(itr);
-		rc = SLURM_SUCCESS;
+	}
+	list_iterator_destroy(itr);
+	
+	itr = list_iterator_create(bgl_list);
+	while ((bgl_record = (bgl_record_t *) list_next(itr)) != NULL)			
+		configure_partition(bgl_record);
+	
+	list_iterator_destroy(itr);
+	rc = SLURM_SUCCESS;
 /* 	} */
 #else
 	if (bgl_list) {
@@ -265,7 +274,7 @@ static int  _validate_config_nodes(void)
 {
 	int rc = SLURM_SUCCESS;
 #ifdef HAVE_BGL_FILES
-	bgl_record_t* conf_record;	/* records from configuration files */
+	bgl_record_t* record;	/* records from configuration files */
 	bgl_record_t* init_record;	/* records from actual BGL config */
 	ListIterator itr_conf, itr_init;
 	char nodes[1024];
@@ -275,33 +284,31 @@ static int  _validate_config_nodes(void)
 		return rc;
 
 	itr_conf = list_iterator_create(bgl_list);
-	while ((conf_record = (bgl_record_t*) list_next(itr_conf))) {
+	while ((record = (bgl_record_t*) list_next(itr_conf))) {
 		/* translate hostlist to ranged string for consistent format */
-		(void) hostlist_ranged_string(conf_record->hostlist,
-			sizeof(nodes), nodes);
         	/* search here */
 		itr_init = list_iterator_create(bgl_init_part_list);
 		while ((init_record = (bgl_record_t*) list_next(itr_init))) {
 //info("%s:%s",nodes, init_record->nodes);
-//info("%d:%d", conf_record->conn_type, init_record->conn_type);
-//info("%d:%d", conf_record->node_use, init_record->node_use);
+//info("%d:%d", record->conn_type, init_record->conn_type);
+//info("%d:%d", record->node_use, init_record->node_use);
 			if (strcmp(nodes, init_record->nodes))
 				continue;	/* wrong nodes */
-			if ((conf_record->conn_type != init_record->conn_type)
-			||  (conf_record->node_use  != init_record->node_use))
+			if ((record->conn_type != init_record->conn_type)
+			||  (record->node_use  != init_record->node_use))
 				break;		/* must reconfig this part */
-			conf_record->bgl_part_id = xstrdup(init_record->
+			record->bgl_part_id = xstrdup(init_record->
 					bgl_part_id);
 			break;
 		}
-		if (!conf_record->bgl_part_id) {
+		if (!record->bgl_part_id) {
 			info("BGL PartitionID:NONE Nodes:%s", nodes);
 			rc = EINVAL;
 		} else {
 			info("BGL PartitionID:%s Nodes:%s Conn:%s Mode:%s",
-				conf_record->bgl_part_id, nodes,
-				convert_conn_type(conf_record->conn_type),
-				convert_node_use(conf_record->node_use));
+				record->bgl_part_id, nodes,
+				convert_conn_type(record->conn_type),
+				convert_node_use(record->node_use));
 		}
 		list_iterator_destroy(itr_init);
 	}
@@ -319,33 +326,33 @@ static int  _validate_config_nodes(void)
  */
 static void _process_config(void)
 {
-	ListIterator itr;
-	bgl_record_t *bgl_part;
-	partition_t* request_result;
-
-	itr = list_iterator_create(bgl_list);
-	while ((bgl_part = (bgl_record_t*) list_next(itr))) {
-		/*
-		 * _parse_request() will fill up the partition_t's
-		 * bl_coord, tr_coord, dimensions, and size
-		 */
-		request_result = NULL;
-		if (_parse_request(bgl_part->nodes, &request_result)
-		|| (request_result == NULL))
-			error("_process_config: error parsing request %s",
-				bgl_part->nodes);
-		else {
-			/*
-			 * bgl_part->conn_type should have been extracted in
-			 * copy_slurm_partition_list
-			 */
-			request_result->bgl_record_ptr = bgl_part;
-			request_result->node_use = bgl_part->node_use;
-			request_result->conn_type = bgl_part->conn_type;
-			bgl_part->alloc_part = request_result;
-		}
-	}
-	list_iterator_destroy(itr);
+/* 	ListIterator itr; */
+/* 	bgl_record_t *bgl_part; */
+/* 	partition_t* request_result; */
+
+/* 	itr = list_iterator_create(bgl_list); */
+/* 	while ((bgl_part = (bgl_record_t*) list_next(itr))) { */
+/* 		/\* */
+/* 		 * _parse_request() will fill up the partition_t's */
+/* 		 * bl_coord, tr_coord, dimensions, and size */
+/* 		 *\/ */
+/* 		request_result = NULL; */
+/* 		if (_parse_request(bgl_part->nodes, &request_result) */
+/* 		|| (request_result == NULL)) */
+/* 			error("_process_config: error parsing request %s", */
+/* 				bgl_part->nodes); */
+/* 		else { */
+/* 			/\* */
+/* 			 * bgl_part->conn_type should have been extracted in */
+/* 			 * copy_slurm_partition_list */
+/* 			 *\/ */
+/* 			request_result->bgl_record_ptr = bgl_part; */
+/* 			request_result->node_use = bgl_part->node_use; */
+/* 			request_result->conn_type = bgl_part->conn_type; */
+/* 			bgl_part->alloc_part = request_result; */
+/* 		} */
+/* 	} */
+/* 	list_iterator_destroy(itr); */
 }
 
 /* 
@@ -363,7 +370,7 @@ static int _copy_slurm_partition_list(List slurm_part_list)
 
 	itr = list_iterator_create(slurm_part_list);
 	/*
-	 * try to find the corresponding bgl_conf_record for the
+	 * try to find the corresponding bgl_record for the
 	 * nodes specified in the slurm_part_list, but if not
 	 * found, _find_conn_type will default to RM_MESH
 	 */
@@ -386,7 +393,7 @@ static int _copy_slurm_partition_list(List slurm_part_list)
 		 * wire each of those bluegene partitions.
 		 */
 		while (cur_nodes != NULL) {
-			bgl_conf_record_t *config_ptr;
+			bgl_record_t *config_ptr;
 			config_ptr = _find_config_by_nodes(cur_nodes);
 			if (config_ptr == NULL) {
 				error("Nodes missing from bluegene.conf: %s",
@@ -398,25 +405,14 @@ static int _copy_slurm_partition_list(List slurm_part_list)
 			bgl_record = (bgl_record_t*) xmalloc(
 					sizeof(bgl_record_t));
 			bgl_record->nodes = xstrdup(cur_nodes);
-			bgl_record->slurm_part_id = xstrdup(slurm_part->name);
-
+			
 			bgl_record->node_use = config_ptr->node_use;
 			bgl_record->conn_type = config_ptr->conn_type;
-			bgl_record->hostlist = hostlist_create(cur_nodes);
-			bgl_record->size = hostlist_count(bgl_record->hostlist);
-			if (node_name2bitmap(cur_nodes, false,
-					&(bgl_record->bitmap))){
-				error("_copy_slurm_partition_list unable to "
-					"convert nodes %s to bitmap",
-					cur_nodes);
-				_destroy_bgl_record(bgl_record);
-				rc = SLURM_ERROR;
-				goto cleanup;
-			}
+			
 
 #if 0	/* Possible future use */
 			if ((slurm_part->min_nodes != slurm_part->max_nodes)
-			||  (bgl_record->size != slurm_part->max_nodes))
+			||  (bgl_record->bp_count != slurm_part->max_nodes))
 				bgl_record->part_lifecycle = DYNAMIC;
 			else
 #endif
@@ -448,7 +444,7 @@ extern int read_bgl_conf(void)
 	int line_num;		/* line number in input file */
 	char in_line[BUFSIZE];	/* input line */
 	int i, j, error_code;
-	bgl_conf_record_t *conf_rec;
+	bgl_record_t *rec;
 	static time_t last_config_update = (time_t) 0;
 	struct stat config_stat;
 
@@ -473,13 +469,13 @@ extern int read_bgl_conf(void)
 		      bgl_conf);
 
 	/* empty the old list before reading new data */
-	if (bgl_conf_list) {
-		while ((conf_rec = list_pop(bgl_conf_list)))
-			_destroy_bgl_conf_record(conf_rec);
-		list_destroy(bgl_conf_list);
-		bgl_conf_list = list_create(NULL);
+	if (bgl_list) {
+		while ((rec = list_pop(bgl_list)))
+			_destroy_bgl_record(rec);
+		list_destroy(bgl_list);
+		bgl_list = list_create(NULL);
 	} else
-		bgl_conf_list = list_create(NULL);
+		bgl_list = list_create(NULL);
 
 	/* process the data file */
 	line_num = 0;
@@ -554,7 +550,7 @@ static int _parse_bgl_spec(char *in_line)
 	char *nodes = NULL, *conn_type = NULL, *node_use = NULL;
 	char *blrts_image = NULL,   *linux_image = NULL;
 	char *mloader_image = NULL, *ramdisk_image = NULL;
-	bgl_conf_record_t* new_record;
+	bgl_record_t* new_record;
 
 	error_code = slurm_parser(in_line,
 				"BlrtsImage=", 's', &blrts_image,
@@ -601,10 +597,11 @@ static int _parse_bgl_spec(char *in_line)
 		goto cleanup;
 	}
 
-	new_record = (bgl_conf_record_t*) xmalloc(sizeof(bgl_conf_record_t));
+	new_record = (bgl_record_t*) xmalloc(sizeof(bgl_record_t));
 	new_record->nodes = nodes;
 	nodes = NULL;	/* pointer moved, nothing left to xfree */
 	
+
 	if (!conn_type || !strcasecmp(conn_type,"TORUS"))
 		new_record->conn_type = SELECT_TORUS;
 	else
@@ -614,8 +611,10 @@ static int _parse_bgl_spec(char *in_line)
 		new_record->node_use = SELECT_COPROCESSOR_MODE;
 	else
 		new_record->node_use = SELECT_VIRTUAL_NODE_MODE;
+	/* printf("this is the type "); */
+/* 	printf("%d\n",new_record->conn_type); */
+	list_append(bgl_list, new_record);
 
-	list_append(bgl_conf_list, new_record);
 #if _DEBUG
 	debug("_parse_bgl_spec: added nodes=%s type=%s use=%s", 
 		new_record->nodes, 
@@ -632,42 +631,32 @@ static void _destroy_bgl_record(void* object)
 	bgl_record_t* this_record = (bgl_record_t*) object;
 
 	if (this_record) {
-		xfree(this_record->nodes);
-		xfree(this_record->slurm_part_id);
-		if (this_record->hostlist)
-			hostlist_destroy(this_record->hostlist);
-		if (this_record->bitmap)
-			bit_free(this_record->bitmap);
-		xfree(this_record->alloc_part);
-		xfree(this_record->bgl_part_id);
+		if(this_record->nodes)
+			xfree(this_record->nodes);
+		if(this_record->owner_name)
+			xfree(this_record->owner_name);
+		if(this_record->bgl_part_list)
+			list_destroy(this_record->bgl_part_list);
+		
+		//xfree(this_record->bgl_part_id);
 		xfree(this_record);
 	}
 }
 
 
-static void _destroy_bgl_conf_record(void* object)
-{
-	bgl_conf_record_t* this_record = (bgl_conf_record_t*) object;
-	if (this_record) {
-		list_destroy(this_record->bgl_part_list);
-		xfree(this_record->nodes);
-		xfree(this_record);
-	}
-}
-
 /* 
  * search through the list of nodes, types to find the partition 
  * containing the given nodes
  */
-static bgl_conf_record_t* _find_config_by_nodes(char* nodes)
+static bgl_record_t* _find_config_by_nodes(char* nodes)
 {
-	return (bgl_conf_record_t*) list_find_first(bgl_conf_list,
-				(ListFindF) _listfindf_conf_part_record,
+	return (bgl_record_t*) list_find_first(bgl_list,
+				(ListFindF) _listfindf_part_record,
 				nodes);
 }
 
-/* Compare node list in bgl_conf_record against node list string */
-static int _listfindf_conf_part_record(bgl_conf_record_t* record, char *nodes)
+/* Compare node list in bgl_record against node list string */
+static int _listfindf_part_record(bgl_record_t* record, char *nodes)
 {
 	return (!strcasecmp(record->nodes, nodes));
 }
@@ -689,78 +678,78 @@ static int _char2num(char in)
  * OUT request_result - allocated data structure (must be xfreed) that 
  *   notes end-points in a node block
  */
-static int _parse_request(char* request_string, partition_t** request_result)
-{
-	int loc = 0, i,j, rc = SLURM_ERROR;
-
-	if (!request_string) {
-		error("_parse_request request_string is NULL");
-		return SLURM_ERROR;
-	}
+/* static int _parse_request(char* request_string, partition_t** request_result) */
+/* { */
+/* 	int loc = 0, i,j, rc = SLURM_ERROR; */
 
-	debug3("bluegene config request %s", request_string);
-	*request_result = (partition_t*) xmalloc(sizeof(partition_t));
+/* 	if (!request_string) { */
+/* 		error("_parse_request request_string is NULL"); */
+/* 		return SLURM_ERROR; */
+/* 	} */
 
-	for (i=0; ; i++) {
-		if (request_string[i] == '\0')
-			break;
-		if (loc == 0) {
-			if (request_string[i] == '[')
-				loc++;
-		} else if (loc == 1) {
-			for (j=0; j<SYSTEM_DIMENSIONS; j++) {
-				(*request_result)->bl_coord[j] =
-						_char2num(request_string[i+j]);
-			}
-			i += (SYSTEM_DIMENSIONS - 1);
-			loc++;
-		} else if (loc == 2) {
-			if (request_string[i] != 'x')
-				break;
-			loc++;
-		} else if (loc == 3) {
-			for (j=0; j<SYSTEM_DIMENSIONS; j++) {
-				(*request_result)->tr_coord[j] =
-						_char2num(request_string[i+j]);
-			}
-			i += (SYSTEM_DIMENSIONS - 1);
-			loc++;
-		} else if (loc == 4) {
-			if (request_string[i] != ']')
-				break;
-			loc++;
-			break;
-		}
-	}
-	if (loc != 5) {
-		error("_parse_request: Mal-formed node list: %s",
-			request_string);
-		/* error("DIM=%d, loc=%d i=%d", SYSTEM_DIMENSIONS, loc, i); */
-		goto cleanup;
-	}
+/* 	debug3("bluegene config request %s", request_string); */
+/* 	*request_result = (partition_t*) xmalloc(sizeof(partition_t)); */
+
+/* 	for (i=0; ; i++) { */
+/* 		if (request_string[i] == '\0') */
+/* 			break; */
+/* 		if (loc == 0) { */
+/* 			if (request_string[i] == '[') */
+/* 				loc++; */
+/* 		} else if (loc == 1) { */
+/* 			for (j=0; j<SYSTEM_DIMENSIONS; j++) { */
+/* 				(*request_result)->bl_coord[j] = */
+/* 						_char2num(request_string[i+j]); */
+/* 			} */
+/* 			i += (SYSTEM_DIMENSIONS - 1); */
+/* 			loc++; */
+/* 		} else if (loc == 2) { */
+/* 			if (request_string[i] != 'x') */
+/* 				break; */
+/* 			loc++; */
+/* 		} else if (loc == 3) { */
+/* 			for (j=0; j<SYSTEM_DIMENSIONS; j++) { */
+/* 				(*request_result)->tr_coord[j] = */
+/* 						_char2num(request_string[i+j]); */
+/* 			} */
+/* 			i += (SYSTEM_DIMENSIONS - 1); */
+/* 			loc++; */
+/* 		} else if (loc == 4) { */
+/* 			if (request_string[i] != ']') */
+/* 				break; */
+/* 			loc++; */
+/* 			break; */
+/* 		} */
+/* 	} */
+/* 	if (loc != 5) { */
+/* 		error("_parse_request: Mal-formed node list: %s", */
+/* 			request_string); */
+/* 		/\* error("DIM=%d, loc=%d i=%d", SYSTEM_DIMENSIONS, loc, i); *\/ */
+/* 		goto cleanup; */
+/* 	} */
 
-	(*request_result)->size = 1;
-	for (i=0; i<SYSTEM_DIMENSIONS; i++) {
-		if (((*request_result)->bl_coord[i] < 0)
-		||  ((*request_result)->tr_coord[i] < 0)) {
-			error("_parse_request: Bad node list values: %s",
-				request_string);
-			goto cleanup;
-		}
-		/* count self */
-		(*request_result)->dimensions[i] =
-			(*request_result)->tr_coord[i] -
-			(*request_result)->bl_coord[i] + 1;
-		(*request_result)->size *=
-			(*request_result)->dimensions[i];
-	}
-	rc = SLURM_SUCCESS;
+/* 	(*request_result)->size = 1; */
+/* 	for (i=0; i<SYSTEM_DIMENSIONS; i++) { */
+/* 		if (((*request_result)->bl_coord[i] < 0) */
+/* 		||  ((*request_result)->tr_coord[i] < 0)) { */
+/* 			error("_parse_request: Bad node list values: %s", */
+/* 				request_string); */
+/* 			goto cleanup; */
+/* 		} */
+/* 		/\* count self *\/ */
+/* 		(*request_result)->dimensions[i] = */
+/* 			(*request_result)->tr_coord[i] - */
+/* 			(*request_result)->bl_coord[i] + 1; */
+/* 		(*request_result)->size *= */
+/* 			(*request_result)->dimensions[i]; */
+/* 	} */
+/* 	rc = SLURM_SUCCESS; */
 	
- cleanup:
-	if (rc == SLURM_ERROR)
-		xfree(*request_result);
-	return rc;
-}
+/*  cleanup: */
+/* 	if (rc == SLURM_ERROR) */
+/* 		xfree(*request_result); */
+/* 	return rc; */
+/* } */
 
 /* Initialize all plugin variables */
 extern int init_bgl(void)
@@ -807,10 +796,7 @@ extern void fini_bgl(void)
 		list_destroy(bgl_list);
 		bgl_list = NULL;
 	}
-	if (bgl_conf_list) {
-		list_destroy(bgl_conf_list);
-		bgl_conf_list = NULL;
-	}
+	
 	if (bgl_init_part_list) {
 		list_destroy(bgl_init_part_list);
 		bgl_init_part_list = NULL;
@@ -838,33 +824,13 @@ extern void print_bgl_record(bgl_record_t* record)
 
 #if _DEBUG
 	info(" bgl_record: ");
-	info("\tslurm_part_id: %s", record->slurm_part_id);
 	if (record->bgl_part_id)
 		info("\tbgl_part_id: %s", record->bgl_part_id);
 	info("\tnodes: %s", record->nodes);
-	info("\tsize: %d", record->size);
+	info("\tsize: %d", record->bp_count);
 	info("\tlifecycle: %s", convert_lifecycle(record->part_lifecycle));
 	info("\tconn_type: %s", convert_conn_type(record->conn_type));
 	info("\tnode_use: %s", convert_node_use(record->node_use));
-
-	if (record->hostlist) {
-		char buffer[BUFSIZE];
-		hostlist_ranged_string(record->hostlist, BUFSIZE, buffer);
-		info("\thostlist %s", buffer);
-	}
-
-	if (record->alloc_part) {
-		info("\talloc_part:");
-		print_partition(record->alloc_part);
-	} else {
-		info("\talloc_part: NULL");
-	}
-
-	if (record->bitmap) {
-		char bitstring[BITSIZE];
-		bit_fmt(bitstring, BITSIZE, record->bitmap);
-		info("\tbitmap: %s", bitstring);
-	}
 #endif
 }
 
@@ -912,9 +878,9 @@ extern char* convert_node_use(rm_partition_mode_t pt)
  */
 static int _bgl_record_cmpf_inc(bgl_record_t* rec_a, bgl_record_t* rec_b)
 {
-	if (rec_a->size < rec_b->size)
+	if (rec_a->bp_count < rec_b->bp_count)
 		return -1;
-	else if (rec_a->size > rec_b->size)
+	else if (rec_a->bp_count > rec_b->bp_count)
 		return 1;
 	else
 		return 0;
diff --git a/src/plugins/select/bluegene/bluegene.h b/src/plugins/select/bluegene/bluegene.h
index e9f1528ff5e05dcaa1897c9f306710600190fcbb..49f69c10ec7870b243c1e3de9bf4560ed1553a0b 100644
--- a/src/plugins/select/bluegene/bluegene.h
+++ b/src/plugins/select/bluegene/bluegene.h
@@ -83,46 +83,46 @@ typedef int lifecycle_type_t;
 enum part_lifecycle {DYNAMIC, STATIC};
 
 typedef struct bgl_record {
-	char* slurm_part_id;		/* ID specified by admins	*/
+	char* nodes;			/* String of nodes in partition */
 	char * owner_name;		/* Owner of partition		*/
 	pm_partition_id_t bgl_part_id;	/* ID returned from CMCS	*/
-	char* nodes;			/* String of nodes in partition */
 	lifecycle_type_t part_lifecycle;/* either STATIC or DYNAMIC	*/
-	hostlist_t hostlist;		/* expanded form of hosts */
-	bitstr_t *bitmap;		/* bitmap of nodes for this partition */
-	struct partition* alloc_part;	/* the allocated partition   */
-	int size;			/* node count for the partitions */
+	rm_partition_state_t state;   	/* the allocated partition   */
+	int coord[SYSTEM_DIMENSIONS];   /* bottom left coordinates */
 	rm_connection_type_t conn_type;	/* Mesh or Torus or NAV */
 	rm_partition_mode_t node_use;	/* either COPROCESSOR or VIRTUAL */
+	rm_partition_t *bgl_part;
+	List bgl_part_list;
+	int bp_count;
+	int switch_count;
 } bgl_record_t;
-/** 
- * structure for use by partitioning algorithm to refer to the
- * structural elements of the BGL partition system.
- */
-typedef struct partition {
-	int bl_coord[SYSTEM_DIMENSIONS]; /* bottom left coordinates */
-	int tr_coord[SYSTEM_DIMENSIONS]; /* top right coordinates */
-	ushort dimensions[SYSTEM_DIMENSIONS]; /* X,Y,Z dimensions */
-	void* bgl_record_ptr;		/* pointer to referring bgl_record */
-	int size;
-	pm_partition_id_t bgl_part_id;	/* ID returned from CMCS	*/
-	ushort conn_type;	/* Type=Mesh/Torus/NAV		*/
-	ushort node_use;	/* Use=Virtual/Coprocessor	*/
-} partition_t;
 
+typedef struct {
+	int source;
+	int target;
+} bgl_conn_t;
+
+typedef struct {
+	int dim;
+	List conn_list;
+} bgl_switch_t;
+
+typedef struct {
+	int *coord;
+	int used;
+	List switch_list;
+} bgl_bp_t;
 
 /*
  * bgl_conf_record is used to store the elements read from the bluegene.conf
  * file and is loaded by init().
  */
-typedef struct bgl_conf_record {
-	char* nodes;
-	rm_connection_type_t conn_type;/* Mesh or Torus or NAV */
-	rm_partition_mode_t node_use;
-	List bgl_part_list;
-	int size;
-	rm_partition_t *bgl_part;
-} bgl_conf_record_t;
+/* typedef struct bgl_conf_record { */
+/* 	char* nodes; */
+/* 	rm_connection_type_t conn_type;/\* Mesh or Torus or NAV *\/ */
+/* 	rm_partition_mode_t node_use; */
+/* 	rm_partition_t *bgl_part; */
+/* } bgl_conf_record_t; */
 
 
 
@@ -174,7 +174,7 @@ char *bgl_err_str(status_t inx);
 
 /* partition_sys.c */
 /*****************************************************/
-int configure_partition(bgl_conf_record_t * bgl_conf_record);
+int configure_partition(bgl_record_t * bgl_conf_record);
 int read_bgl_partitions();
 
 /* state_test.c */
@@ -223,6 +223,6 @@ int term_job(struct job_record *job_ptr);
 
 /* bgl_switch_connections.c */
 /*****************************************************/
-int configure_partition_switches(bgl_conf_record_t * bgl_conf_record);
+int configure_partition_switches(bgl_record_t * bgl_conf_record);
 
 #endif /* _BLUEGENE_H_ */
diff --git a/src/plugins/select/bluegene/partition_sys.c b/src/plugins/select/bluegene/partition_sys.c
index 1a182b70f42784748cefed9c65b2a464bda5886a..bc0a198ab1f98f1b5365ea78e08f2a26f11fef74 100755
--- a/src/plugins/select/bluegene/partition_sys.c
+++ b/src/plugins/select/bluegene/partition_sys.c
@@ -60,8 +60,8 @@ List bgl_init_part_list = NULL;	/* Initial bgl partition state */
 // static int  _get_bp(rm_element_t *bp, rm_location_t *loc);
 /*    static int  _is_not_equals_all_coord (int* rec_a, int* rec_b); */
 /*    static int  _is_not_equals_some_coord(int* rec_a, int* rec_b); */
-   static void _pre_allocate(bgl_conf_record_t *bgl_conf_record);
-   static int _post_allocate(rm_partition_t *my_part);
+   static void _pre_allocate(bgl_record_t *bgl_record);
+   static int _post_allocate(bgl_record_t *bgl_record);
 // static int _get_switch_list(partition_t* partition, List* switch_list);
 
 /* static int  _create_bgl_partitions(List requests); */
@@ -83,20 +83,6 @@ static int  _post_bgl_init_read(void *object, void *arg);
 /*   extern void debug(const char *fmt, ...); */
 /* #endif */
 
-void print_partition(partition_t* part)
-{
-	if (part == NULL)
-		return;
-
-	debug("\tdimensions: [ %d %d %d ]", part->dimensions[0], 
-	      part->dimensions[1], part->dimensions[2]);
-	debug("\tbl coord:   [ %d %d %d ]", part->bl_coord[0], 
-	      part->bl_coord[1], part->bl_coord[2]);
-	debug("\ttr coord:   [ %d %d %d ]", part->tr_coord[0], 
-	      part->tr_coord[1], part->tr_coord[2]);
-	debug("\tsize: %d", part->size);
-	debug("\tbgl_record_ptr addr: %d", part->bgl_record_ptr);
-}
 /** 
  * print out a list
  */
@@ -128,84 +114,85 @@ void print_list(List list)
 	list_iterator_destroy(itr);
 }
 
-/** 
- * print out list of the system partitions
- */
-void print_sys_list(List list)
-{
-	ListIterator itr;
-	int i, part_count=0;
-	partition_t* stuff;
+/* /\**  */
+/*  * print out list of the system partitions */
+/*  *\/ */
+/* void print_sys_list(List list) */
+/* { */
+/* 	ListIterator itr; */
+/* 	int i, part_count=0; */
+/* 	partition_t* stuff; */
 
-	if (list == NULL){
-		debug("List is empty (NULL)");
-		return;
-	}
+/* 	if (list == NULL){ */
+/* 		debug("List is empty (NULL)"); */
+/* 		return; */
+/* 	} */
 
-	itr = list_iterator_create(list);
-	while ((stuff = (partition_t*) list_next(itr))) {
-		if (stuff == NULL){
-			break; 
-		}
+/* 	itr = list_iterator_create(list); */
+/* 	while ((stuff = (partition_t*) list_next(itr))) { */
+/* 		if (stuff == NULL){ */
+/* 			break;  */
+/* 		} */
 
-		debug("part %d: dimensions [ %d", part_count++, stuff->dimensions[0]);
-		for (i=1; i<SYSTEM_DIMENSIONS; i++){
-			debug(" x %d", stuff->dimensions[i]);
-		}
-		debug(" ]");
+/* 		debug("part %d: dimensions [ %d", part_count++, stuff->dimensions[0]); */
+/* 		for (i=1; i<SYSTEM_DIMENSIONS; i++){ */
+/* 			debug(" x %d", stuff->dimensions[i]); */
+/* 		} */
+/* 		debug(" ]"); */
 
-		debug("bl coord [ %d", stuff->bl_coord[0]);
-		for (i=1; i<SYSTEM_DIMENSIONS; i++){
-			debug(" x %d", stuff->bl_coord[i]);
-		}
-		debug(" ]");
+/* 		debug("bl coord [ %d", stuff->bl_coord[0]); */
+/* 		for (i=1; i<SYSTEM_DIMENSIONS; i++){ */
+/* 			debug(" x %d", stuff->bl_coord[i]); */
+/* 		} */
+/* 		debug(" ]"); */
 
-		debug("tr coord [ %d", stuff->tr_coord[0]);
-		for (i=1; i<SYSTEM_DIMENSIONS; i++){
-			debug(" x %d", stuff->tr_coord[i]);
-		}
-		debug(" ]");
+/* 		debug("tr coord [ %d", stuff->tr_coord[0]); */
+/* 		for (i=1; i<SYSTEM_DIMENSIONS; i++){ */
+/* 			debug(" x %d", stuff->tr_coord[i]); */
+/* 		} */
+/* 		debug(" ]"); */
 
-	}
-	list_iterator_destroy(itr);
-}
+/* 	} */
+/* 	list_iterator_destroy(itr); */
+/* } */
 /** 
  * initialize the BGL partition in the resource manager 
  */
-static void _pre_allocate(bgl_conf_record_t *bgl_conf_record)
+static void _pre_allocate(bgl_record_t *bgl_record)
 {
-	rm_set_data(bgl_conf_record->bgl_part, RM_PartitionBlrtsImg,   bluegene_blrts);
-	rm_set_data(bgl_conf_record->bgl_part, RM_PartitionLinuxImg,   bluegene_linux);
-	rm_set_data(bgl_conf_record->bgl_part, RM_PartitionMloaderImg, bluegene_mloader);
-	rm_set_data(bgl_conf_record->bgl_part, RM_PartitionRamdiskImg, bluegene_ramdisk);
-	rm_set_data(bgl_conf_record->bgl_part, RM_PartitionConnection, &bgl_conf_record->conn_type);
-	rm_set_data(bgl_conf_record->bgl_part, RM_PartitionMode, &bgl_conf_record->node_use);
-	rm_set_data(bgl_conf_record->bgl_part, RM_PartitionUserName, USER_NAME);
+	rm_set_data(bgl_record->bgl_part, RM_PartitionBlrtsImg,   bluegene_blrts);
+	rm_set_data(bgl_record->bgl_part, RM_PartitionLinuxImg,   bluegene_linux);
+	rm_set_data(bgl_record->bgl_part, RM_PartitionMloaderImg, bluegene_mloader);
+	rm_set_data(bgl_record->bgl_part, RM_PartitionRamdiskImg, bluegene_ramdisk);
+	rm_set_data(bgl_record->bgl_part, RM_PartitionConnection, &bgl_record->conn_type);
+	rm_set_data(bgl_record->bgl_part, RM_PartitionMode, &bgl_record->node_use);
+	rm_set_data(bgl_record->bgl_part, RM_PartitionUserName, USER_NAME);
 }
 
 /** 
  * add the partition record to the DB and boot it up!
  */
-static int _post_allocate(rm_partition_t *my_part)
+static int _post_allocate(bgl_record_t *bgl_record)
 {
 	int rc;
 //	rm_partition_state_t state=RM_PARTITION_READY;
 	pm_partition_id_t part_id;
 	char command[100];
+	
 	/* Add partition record to the DB */
 	printf("adding partition\n");
 	//my_part->description = "Stand-alone mpirun";
-	rc = rm_add_partition(my_part);
+	rc = rm_add_partition(bgl_record->bgl_part);
 	if (rc != STATUS_OK) {
 		error("Error adding partition");
 		return(-1);
 	}
 	printf("done adding\n");
-
+	
 	/* Get back the new partition id */
-	rm_get_data(my_part, RM_PartitionID, &part_id);
+	rm_get_data(bgl_record->bgl_part, RM_PartitionID, &part_id);
 	/* We are done with the partition */
-	rm_free_partition(my_part);
+	rm_free_partition(bgl_record->bgl_part);
 	//exit(0);
 	/* Initiate boot of the partition */
 	/*debug("Booting Partition %s", part_id);
@@ -216,7 +203,7 @@ static int _post_allocate(rm_partition_t *my_part)
 		}*/
 
 	/* Wait for Partition to be booted */
-	rc = rm_get_partition(part_id, &my_part);
+	rc = rm_get_partition(part_id, &bgl_record->bgl_part);
 	if (rc != STATUS_OK) {
 		error("Error in GetPartition");
 		return(-1);
@@ -224,22 +211,27 @@ static int _post_allocate(rm_partition_t *my_part)
 	memset(command,0,100);
 	sprintf(command,"/home/da/allocate_block %s %s", part_id, USER_NAME);
 	system(command);
-	
-	//rm_set_data(my_part, RM_PartitionState, state);
+
+	rm_get_data(bgl_record->bgl_part, RM_PartitionID, &bgl_record->bgl_part_id);
+	bgl_record->nodes = xstrdup(bgl_record->nodes);
+		
+	bgl_record->node_use = bgl_record->node_use;
+	bgl_record->conn_type = bgl_record->conn_type;
+	list_push(bgl_list, bgl_record);
 	fflush(stdout);
 
 	return 0;
 }
 
 
-int configure_partition(bgl_conf_record_t *bgl_conf_record)
+int configure_partition(bgl_record_t *bgl_record)
 {
-	rm_new_partition(&bgl_conf_record->bgl_part); /* new partition to be added */
-	_pre_allocate(bgl_conf_record);
+	rm_new_partition(&bgl_record->bgl_part); /* new partition to be added */
+	_pre_allocate(bgl_record);
 	
-	configure_partition_switches(bgl_conf_record);
+	configure_partition_switches(bgl_record);
 	
-	_post_allocate(bgl_conf_record->bgl_part); 
+	_post_allocate(bgl_record); 
 	return 1;
 }
 	
@@ -800,60 +792,6 @@ int max_dim_index(int* array)
 	return max_index;
 }
 
-/** 
- * rotate the given partition configuration into decreasing
- * order. (ie, 2,1,4 -> 4,2,1).  
- * 
- * note: this is for 3d only!
- */
-void rotate_part(const uint16_t* config, uint16_t** new_config)
-{
-	if (config == NULL)
-		return;
-
-	xfree(*new_config);
-	(*new_config) = (uint16_t*) xmalloc(SYSTEM_DIMENSIONS * 
-		sizeof(uint16_t));
-
-	if (config[0] > config[1]){
-		if (config[1] > config[2]){
-			; // array already sorted
-		} else {
-			if (config[0] > config[2]){
-				(*new_config)[0] = config[0];
-				(*new_config)[1] = config[2];
-				(*new_config)[2] = config[1];
-				return;
-			} else {
-				(*new_config)[0] = config[2];
-				(*new_config)[1] = config[0];
-				(*new_config)[2] = config[1];
-				return;
-			}
-		}
-	/* config[0] <= config[1] */
-	} else {
-		if (config[1] > config[2]){
-			if (config[0] > config [2]){
-				(*new_config)[0] = config[1];
-				(*new_config)[1] = config[0];
-				(*new_config)[2] = config[2];
-				return;
-			} else {
-				(*new_config)[0] = config[1];
-				(*new_config)[1] = config[2];
-				(*new_config)[2] = config[0];
-				return;
-			}
-		} else {
-			(*new_config)[0] = config[2];
-			(*new_config)[1] = config[1];
-			(*new_config)[2] = config[0];
-			return;
-		}
-	}
-}
-
 /** 
  * get the initial configuration of the BGL system (or clean it up so
  * that we know what we're dealing with).
@@ -1027,7 +965,6 @@ int read_bgl_partitions()
 			bgl_part_ptr = xmalloc(sizeof(bgl_record_t));
 			list_push(bgl_init_part_list, bgl_part_ptr);
 			bgl_part_ptr->bgl_part_id = xstrdup(part_id);
-			bgl_part_ptr->hostlist = hostlist_create(node_name_tmp);
 			if ((rm_rc = rm_get_data(part_ptr,
 					RM_PartitionConnection,
 					&bgl_part_ptr->conn_type))
@@ -1058,12 +995,9 @@ int read_bgl_partitions()
 				error("rm_free_partition(): %s",
 					bgl_err_str(rm_rc));
 			}
-		} else {
-			/* Add node name to existing BGL partition record */
-			hostlist_push(bgl_part_ptr->hostlist, node_name_tmp);
 		}
 
-		(bgl_part_ptr->size)++;
+		bgl_part_ptr->bp_count++;
 	}
 
 	/* perform post-processing for each bluegene partition */
@@ -1074,17 +1008,17 @@ int read_bgl_partitions()
 /* #ifdef HAVE_BGL_FILES */
 static int _post_bgl_init_read(void *object, void *arg)
 {
-	bgl_record_t *bgl_part_ptr = (bgl_record_t *) object;
-	int i = 1024;
-
-	bgl_part_ptr->nodes = xmalloc(i);
-	while (hostlist_ranged_string(bgl_part_ptr->hostlist, i,
-			bgl_part_ptr->nodes) < 0) {
-		i *= 2;
-		xrealloc(bgl_part_ptr->nodes, i);
-	}
+	/* bgl_record_t *bgl_part_ptr = (bgl_record_t *) object; */
+/* 	int i = 1024; */
+
+/* 	bgl_part_ptr->nodes = xmalloc(i); */
+/* 	while (hostlist_ranged_string(bgl_part_ptr->hostlist, i, */
+/* 			bgl_part_ptr->nodes) < 0) { */
+/* 		i *= 2; */
+/* 		xrealloc(bgl_part_ptr->nodes, i); */
+/* 	} */
 
-	print_bgl_record(bgl_part_ptr);
+/* 	print_bgl_record(bgl_part_ptr); */
 
 	return SLURM_SUCCESS;
 }
@@ -1096,13 +1030,6 @@ static void _part_list_del(void *object)
 	if (part_ptr) {
 		xfree(part_ptr->bgl_part_id);
 		xfree(part_ptr->nodes);
-		xfree(part_ptr->slurm_part_id);
-		if (part_ptr->bitmap) {
-			bit_free(part_ptr->bitmap);
-			part_ptr->bitmap = NULL;
-		}
-		if (part_ptr->hostlist)
-			hostlist_destroy(part_ptr->hostlist);
 		xfree(part_ptr);
 	}
 }