     __shared__ REAL Cs[MULTIPLY_BLOCK_SIZE];
     __shared__ REAL Ds[MULTIPLY_BLOCK_SIZE];
     __shared__ REAL Es[MULTIPLY_BLOCK_SIZE + 2];
-    
+
    	REAL* B0  = &Bs[1][0];
    	REAL* Bm1 = &Bs[0][0];
-   	REAL* Bp1 = &Bs[2][0];    	
+   	REAL* Bp1 = &Bs[2][0];
    	REAL* E0  = &Es[1];
-   	
+
    	// Zero first row of Bs and Es
    	if (ty == 0) {
    		Bs[0][tx] = 0;
    		if (tx == 0) {
-   			Es[0] = 0;	
+   			Es[0] = 0;
    		}
    	}
 
-    for (int i = 0; i < BLOCKS - 1; i++) {
+    while (d + MULTIPLY_BLOCK_SIZE < PADDED_STATE_COUNT) {
 
         READ_SCHUR_VALUES();
 


    // All necessary values loaded
	__syncthreads();
	
	POPULATE_SCHUR_BAND(EDGE);

	__syncthreads();


    // Write the block sub-matrix to device memory;
    // each thread writes one element

    if (Csub < 0)
    	Csub = 0;

