Performance Issue probably run out of Ram

  const int bytesX[totalNumberOfMatrices][8] =  {  {127, 191, 223, 239, 247, 251, 253, 254}, 
                                                   {127, 191, 223, 239, 247, 251, 253, 254},
                                                   {254, 253, 251, 247, 239, 223, 191, 127},
                                                   {254, 253, 251, 247, 239, 223, 191, 127},
                                                };

All those values would fit in a byte array, cutting the array size in half.