 			}
 
 		}
-		__syncthreads();
-		//Fill edges
+
+		// Fill edges.  Thread 0 never gets used for both operations so the calculation and the
+		// filling are conceptually coincident.
 		if (k>2 && tid == 0)
 		{
 			temper[(k-3)+(34*shft_wr)] = sL[itr];

#define DIVISIONS  1024.
#define LENX       50.
#define TS         .5
#define TIMELIMIT  5000.
#define REAL       float
#define TH_DIFF    8.418e-5



		__syncthreads();


	}
	//Now there is only global fill to handle.

	if (blockIdx.x > 0)
	{
		//True if it ends on the first row! The first and last of temper on the final row are empty.
		IC[gid - 16] = temper[tid+1];
	}
	else
	{
		if (tid>15)
		{
			IC[gid - 16] = temper[tid+2];
		}
		else
		{
			IC[(blockDim.x * gridDim.x) + (tid - 16) ] = temper[tid+2];
		}
	}

}


int main()
{

	cudaSetDevice(0);
	const int dv = int(DIVISIONS);
	const int bks = dv/32;
	const REAL ds = LENX/(DIVISIONS-1);
	REAL fou = TS*TH_DIFF/(ds*ds);

	REAL IC[dv];
	REAL T_final[dv];
	REAL *d_IC, *d_right, *d_left;

	for (int k = 0; k<dv; k++)
