proc createCells(){ local i, ij, si, pci, cellind, runresult, gid	// Create cells and assign a GID to each cell
	for cellind=0, numCellTypes-1 {																		//	number stream have already been used
		for pcitr(&i, &ij, &gid, cellType[cellind].cellStartGid, cellType[cellind].cellEndGid) {// use the pciter over all cells of this type
			if (pc.gid_exists(gid)) {
				sprint(cmd, "cellType[%g].CellList[%g]=new %s(%g,%g)", cellind, ij, cellType[cellind].technicalType, gid, i) //+cellType[cellind].cellStartGid) // why add the startgid to the gid? 

				{runresult=execute1(cmd)} 		// This command was written as a string so
												//	the cell object doesn't have to be hard coded
												
				cells.append(cellType[cellind].CellList[ij])	// Append each cell to cells list
				cellType[cellind].numThisHost = ij+1 // set number of cells of this type on this host (but add 1 b/c ij is zero based)

				// Random streams
				// randomlist.append(new RandomStream(highIndex, lowIndex)
				// each cell can make use of three different random streams, specified with lowIndexes based on the cell's gid:
				//		lowIndex		Stream Name		Stream Purpose
				//		gid				n/a				Used in the fastconn/repeatconn mechanisms to determine which cells are connected
				//		gid + 1*ncell	ransynlist		Used in the connectivity hoc file to determine which synapses are used in each connection formed
				//		gid + 2*ncell	ranstimlist		Used in the stimulation hoc file (only by NetStims) to randomize the stimulation of the network
				//
				// Running independent simulations:
				//	Set the highIndex starting values using the RandomSeeds variable
				//	Make sure that simulations are independent of each other by checking that the beginning and end highIndex values
				//	 of each simulation DO NOT OVERLAP.
				//	The beginning highIndex value is always = 1+RandomSeeds.
				//	The max ending highIndex value used by each type of stream is printed in the MaxHighIndex.txt file.
				//	Consult the MaxHighIndex.txt file of a previous run, and then set RandomSeeds higher than any of its values,
				//	 to make your next run statistically independent
				//
				// To run the same network under different conditions (under different stimulation), only change RandomSeedsStim (the highIndex for ranstimlist)
				// To run different networks under the same conditions (using different connectivity), only change RandomSeedsConn (the highIndex for ransynlist and the connectivity stream)
				ransynlist.append(new RandomStream(1+RandomSeedsConn, gid + 1*ncell)) // Create a new random number generator for each cell,
															//	with a unique stream. This will be used to determine
															//	what type of synapse is used in connections
															// lowindex = gid is used in the connection algorithm in the mod file
				ranstimlist.append(new RandomStream(1+RandomSeedsStim, gid + 2*ncell)) // Create a new random number generator for each cell, used by netstims for setting spont stim.

				cellType[cellind].CellList[ij].connect_pre(nil, nc)	// Create an empty connection for use by the spike detector
				pc.cell(gid, nc)									// Associate the cell with its gid and its spike generation location
				
				if (cellType[cellind].CellList[ij].is_art==0) {									// For non ppstim cells, assign position, initialize synapse cid and sid				
					for si=0, cellType[cellind].CellList[ij].pre_list.count-1 {	// Iterate over each pre cell type's synapse list
						for j=0, cellType[cellind].CellList[ij].pre_list.o(si).count-1 {		// Iterate through each synapse in the list
							cellType[cellind].CellList[ij].pre_list.o(si).o(j).cid=gid			// Set the cell id for each synapse
																								//  Note: Parameters added to Syn2Gid mechanism
						}
					}

					if ((ij%int(cellType[cellind].numCells/10+1) == 0) && (PrintTerminal>1)) {
					print cellType[cellind].cellType_string, ": ", i
					}
				}				
				
				xpos=xpos_algorithm(gid,cellType[cellind].numCells,cellType[cellind].cellStartGid,cellType[cellind].dentateXBins,cellType[cellind].dentateYBins*cellType[cellind].dentateZBins,cellType[cellind].dentateXBinSize)	// Algorithmically generate cell position
				ypos=ypos_algorithm(gid,cellType[cellind].numCells,cellType[cellind].cellStartGid,cellType[cellind].dentateYBins,cellType[cellind].dentateZBins,cellType[cellind].dentateYBinSize)	// Algorithmically generate cell position
				zpos=zpos_algorithm(gid,cellType[cellind].numCells,cellType[cellind].cellStartGid,cellType[cellind].dentateZBins,cellType[cellind].dentateZBinSize,cellType[cellind].layerflag)	// Algorithmically generate cell position
				cellType[cellind].CellList[ij].position(xpos,ypos,zpos)									// Record cell position in cell object
								
			}
		} 
	}

	nc = nil // Then clear the reference to the netcon object, which should destroy the netcon (because all refs would have been removed)
	if  (PrintTerminal>0) {print "Host ", pc.id, " created cells."}
}
createCells()