Well how are you sending the data, if you send a string with a null terminator you need to account for it.
You could flush all remaining characters.
//Get new mode if available
if(Serial.available()){
mode = Serial.read();
while( Serial.available() ) Serial.read();
}
Or maybe even better, check if the character is what you are looking for:
//Get new mode if available
if(Serial.available()){
char temp = Serial.read();
if( ( temp >= '1' ) && ( temp <= '5' ) ){
mode = temp;
}
}