 * @param p matrix of predecessors p(G)
 */
 
-template <int BLOCK_SIZE, int THREAD_SIZE> __global__ void fw_kernel_phase_three(const unsigned int block, const unsigned int n, const size_t pitch, int * const d, int * const p)
+template <int BLOCK_SIZE, int THREAD_SIZE> __global__ void fw_kernel_phase_three(unsigned int block, const unsigned int n, const size_t pitch, int * const d, int * const p)
 {
 	if (blockIdx.x == block || blockIdx.y == block) return;
-	int i, j, k;
+	int i, j, k;	
 	int newPath;
+	int predecessor;
 	int path;
-	int predecessor;
-
-	int tx = threadIdx.x * THREAD_SIZE;
-	int ty = threadIdx.y * THREAD_SIZE;
-
-	int v1 = blockDim.y * blockIdx.y * THREAD_SIZE + ty;
-	int v2 = blockDim.x * blockIdx.x * THREAD_SIZE + tx;
-
-	int v1Row = BLOCK_SIZE * block * THREAD_SIZE + ty;
-	int v2Row = v2;
-	
-	int v1Col = v1;
-	int v2Col = BLOCK_SIZE * block * THREAD_SIZE + tx;
-	
+
+	const int tx = threadIdx.x * THREAD_SIZE;
+	const int ty = threadIdx.y * THREAD_SIZE;
+
+	const int v1 = blockDim.y * blockIdx.y * THREAD_SIZE + ty;
+	const int v2 = blockDim.x * blockIdx.x * THREAD_SIZE + tx;
+
 	int idx, idy;
-	int cell_col;
-	int cell_row;
-	int cell;
 	
 	__shared__ int primaryRow_d[BLOCK_SIZE * THREAD_SIZE][BLOCK_SIZE * THREAD_SIZE];
 	__shared__ int primaryCol_d[BLOCK_SIZE * THREAD_SIZE][BLOCK_SIZE * THREAD_SIZE];
 	__shared__ int primaryRow_p[BLOCK_SIZE * THREAD_SIZE][BLOCK_SIZE * THREAD_SIZE];
 	
+	int v1Row = BLOCK_SIZE * block * THREAD_SIZE + ty;
+	int v2Col = BLOCK_SIZE * block * THREAD_SIZE + tx;
+
 	// Load data for virtual block
 	#pragma unroll
 	FOR (i, 0, THREAD_SIZE - 1)

	}
	
	const int cell_current = v1 * pitch + v2;

	if (v1 < n && v2 < n)
	{
		current_d[ty][tx] = d[cell_current];

        int newPath;
	int newPred;

	int tx = threadIdx.x;
        int ty = threadIdx.y;

	int v1 = BLOCK_SIZE * block + ty;
        int v2 = BLOCK_SIZE * block + tx;
	
	__shared__ int primary_d[BLOCK_SIZE][BLOCK_SIZE];
	__shared__ int current_d[BLOCK_SIZE][BLOCK_SIZE];
