     if (!is_ski && memcmp("HEX", p->name+8, 3)) continue;
 
     /* Locate this sketch name in the memory buffer */
-    uint16_t sketch_index = 0;
-    int16_t sketch_addr = sketches_sram_start;
+    sketch_index = 0;
+    sketch_addr = sketches_sram_start;
     boolean create_new = true;
-    while (sketch_index < sketches_cnt) {
+    while (sketch_index < sketches_buff_cnt) {
       if (sketch_addr >= 0) {
         /* Reading SRAM space - turn the SD-card off */
         card_setEnabled(false);

 * The remaining ~2730 entries are stored on the External SRAM chip
 */
SketchInfo sketches_buff[100];
int sketches_cnt = 0;
const int16_t sketches_sram_start = -sizeof(sketches_buff);
boolean sketches_reachedEnd = false;


          /* Pressed? */
          uint8_t color;
          if (touchedIndex == i) {
            color = COLOR_EDIT_SEL;
          } else {
            color = button_color[i];
          }

          /* Draw the sketch icon */
          LCD_write_icon(px, py, 48, 48, button_icon[i], button_title[i], COLOR_EDIT_BG, color);
        }
      }
    }
