                                                          REAL* dParentPartials,
                                                          int* dChildStates,
                                                          REAL* dTransMatrix,
-                                                         int patternCount) {
+                                                         int totalPatterns) {
     REAL sum1 = 0;
 
-    int tx = threadIdx.x;
-    int state = tx % 4;
-    int pat = tx / 4;
-    int patIdx = threadIdx.y;
-    int matrix = blockIdx.y;
-    int totalPatterns = patternCount; // gridDim.x;
-
-    // read 4 patterns at a time, since 4 * 4 = 16
-    int pattern = __umul24(blockIdx.x, PATTERN_BLOCK_SIZE * 4) + patIdx * 4 + pat;
-
-    int deltaPartialsByState = 4 * 4 * (blockIdx.x * PATTERN_BLOCK_SIZE + patIdx);
-    int deltaPartialsByMatrix = __umul24(matrix, __umul24( PADDED_STATE_COUNT, patternCount));
-
-    int x2 = __umul24(matrix, PADDED_STATE_COUNT * PADDED_STATE_COUNT);
-
+    DETERMINE_INDICES_4();
+    int y = deltaPartialsByState + deltaPartialsByMatrix;
     REAL* matrix1 = dTransMatrix + x2; // Points to *this* matrix
-
-    int y = deltaPartialsByState + deltaPartialsByMatrix;
-    int u = tx + deltaPartialsByState + deltaPartialsByMatrix;
-
+    
 #ifdef KERNEL_PRINT_ENABLED
     printf("matrix = %d, pat = %d for tx = %d and state = %d :  u = %d\n", matrix, pattern, tx,
            state, u);

                                                              REAL* dParentPartials,
                                                              REAL* dChildParials,
                                                              REAL* dTransMatrix,
                                                              int patternCount) {
    REAL sum1 = 0;

    int i;

    int tx = threadIdx.x;
    int state = tx % 4;
    int pat = tx / 4;
    int patIdx = threadIdx.y;
    int matrix = blockIdx.y;
    int totalPatterns = patternCount; // gridDim.x;

    // read 4 patterns at a time, since 4 * 4 = 16 
    int pattern = __umul24(blockIdx.x, PATTERN_BLOCK_SIZE * 4) + patIdx * 4 + pat;

    int deltaPartialsByState = 4 * 4 * (blockIdx.x * PATTERN_BLOCK_SIZE + patIdx);
    int deltaPartialsByMatrix = __umul24(matrix, __umul24( PADDED_STATE_COUNT, totalPatterns));

    int x2 = __umul24(matrix, PADDED_STATE_COUNT * PADDED_STATE_COUNT);

    REAL* matrix1 = dTransMatrix + x2; // Points to *this* matrix

    int y = deltaPartialsByState + deltaPartialsByMatrix;
    int u = tx + deltaPartialsByState + deltaPartialsByMatrix;

#ifdef KERNEL_PRINT_ENABLED
    printf("matrix = %d, pat = %d for tx = %d and state = %d :  u = %d\n", matrix, pattern, tx,

    REAL sum2;
    int i;

    DETERMINE_INDICES_4();
    int y = deltaPartialsByState + deltaPartialsByMatrix;
    REAL* matrix1 = matrices1 + x2; // Points to *this* matrix
    REAL* matrix2 = matrices2 + x2;


//    int y = deltaPartialsByState + deltaPartialsByMatrix;
//    int u = tx + deltaPartialsByState + deltaPartialsByMatrix;

#ifdef KERNEL_PRINT_ENABLED
    printf("matrix = %d, pat = %d for tx = %d and state = %d :  u = %d\n", matrix, pattern, tx,
