 
   base64_decode(decoded, (char*)dataArray, realSize);
 
-  String messageString = String(decoded);
-
-  boolean isConfigurationMessage = messageString.indexOf('{') != -1 && messageString.indexOf('}') != -1;
-
-  lcd.clear();
-  lcd.print(messageString);
+  boolean isConfigurationMessage = strchr(decoded, '{') != NULL;
+
   if (isConfigurationMessage) {
-    byte configurationType = getConfigurationType(messageString);
+    byte configurationType = getConfigurationType(decoded + 1);
     switch (configurationType) {
       case SONG_CONFIGURATION:
-        handleSongConfiguration(messageString);
+        handleSongConfiguration(decoded + 4);
         break;
-    }
-  }
-
-}
-
-void handleSongConfiguration(String message) {
-  byte indexStart = message.indexOf('}') + 1;
-  byte index = message.substring(message.indexOf('{', indexStart) + 1, message.indexOf('}', indexStart)).toInt();
-  Serial.print(index);
-  Serial.print(" ");
-  byte songStart = message.indexOf('}', indexStart) + 1;
-  String song = message.substring(message.indexOf('{', songStart) + 1, message.indexOf('}', songStart));
-  Serial.println(song);
-  int strLen = song.length() + 1;
-  char charArray[strLen];
-  song.toCharArray(charArray, strLen);
-  songs[index] = charArray;
-
+      case CONFIGURATION_START:
+        handleConfigurationStart();
+        break;
+      case CONFIGURATION_FINISHED:
+        handleConfigurationFinished();
+        break;
+    }
+  }
+}
+
+void handleConfigurationStart() {
+  lcd.clear();
+  lcd.print(F("Configuration"));
+  lcd.setCursor(0, 1);
+  lcd.print(F("start"));
+}
+
+void handleConfigurationFinished() {
+#ifdef SONG_CONFIGURATION_DEBUG
   for (byte i = 0; i < numberOfSongs; i++) {
     if (songs[i]) {
       Serial.print(i);
-      Serial.print(" ");
+      Serial.print(F(" "));
       Serial.println(songs[i]);
     }
   }
-}
-
-byte getConfigurationType(String message) {
-  String configurationString = message.substring(message.indexOf('{') + 1, message.indexOf('}'));
-  if (configurationString.equals("C")) {
+#endif
+  lcd.clear();
+  lcd.print(F("Configuration"));
+  lcd.setCursor(0, 1);
+  lcd.print(F("finished"));
+
+  allLedsTest();
+  lcd.clear();
+
+  mode = NORMAL_MODE;
+  selectedSong = 0;
+  handleNormalMode(true);
+}
+
+void handleSongConfiguration(char* messageOriginal) {
+  char* message = (char*)calloc(strlen(messageOriginal) + 1, sizeof(char));
+  strcpy(message, messageOriginal);
+  char* strings;
+  strings = strtok(message, "|");
+  if (strings == NULL) {
+    return;
+  }
+
+  byte index = atoi(strings);
+
+  strings = strtok(NULL, "|");
+  if (strings == NULL) {
+    return;
+  }
+
+#ifdef SONG_CONFIGURATION_DEBUG
+  Serial.print(F("Received song configuration "));
+  Serial.print(index);
+  Serial.print(F(" "));
+  Serial.println(strings);
+#endif
+
+  songs[index - 1] = strings;
+}
+
+byte getConfigurationType(char* messageOriginal) {
+  char* message = (char*)calloc(strlen(messageOriginal) + 1, sizeof(char));
+  strcpy(message, messageOriginal);
+  char* strings;
+  strings = strtok(message, "|");
+  if (strings == NULL) {
+    return -1;
+  }
+  if (strcmp(strings , "SC") == 0) {
     return SONG_CONFIGURATION;
+  } else if (strcmp(strings , "CS") == 0) {
+    return CONFIGURATION_START;
+  } else if (strcmp(strings , "CF") == 0) {
+    return CONFIGURATION_FINISHED;
   }
   return -1;
 }

    update = true;
  }
  if (update) {
    Serial.print("MIDI offset ");
    Serial.println(initBank);
  }
}

void handleNormalMode() {
  changeBank();
}

boolean changeMode() {

//#define DEBUG_BUTTONS true
//#define SINGLE_LED_TEST true
//#define LCD_TEST true
#define SONG_CONFIGURATION_DEBUG true

byte counter;
const byte CLOCK = 248;
