                                                                   REAL* matrices1,
                                                                   REAL* matrices2,
                                                                   int totalPatterns) {
-    REAL sum1 = 0;
-    REAL sum2 = 0;
+    REAL sum1;
+    REAL sum2;
     int i;
 
     int tx = threadIdx.x;
-    int state = tx % 4;
+    int state = tx & 0x3; //  tx % 4;
     int pat = tx / 4;
     int patIdx = threadIdx.y;
     int matrix = blockIdx.y;


    __shared__ REAL sPartials1[PATTERN_BLOCK_SIZE * 4 * 4];
    __shared__ REAL sPartials2[PATTERN_BLOCK_SIZE * 4 * 4];

    // copy PADDED_STATE_COUNT * PATTERN_BLOCK_SIZE lengthed partials
    if (pattern < totalPatterns) {

                                                                REAL* matrices1,
                                                                REAL* matrices2,
                                                                int totalPatterns) {
    REAL sum1 = 1;
    REAL sum2;
    int i;

    int tx = threadIdx.x;
    int state = tx & 0x3; //  tx % 4;
    int pat = tx / 4;
    int patIdx = threadIdx.y;
    int matrix = blockIdx.y;
