diff --git a/src/sound/music.cpp b/src/sound/music.cpp
index cc2a183ff..f211f2ee7 100644
--- a/src/sound/music.cpp
+++ b/src/sound/music.cpp
@@ -482,6 +482,14 @@ global void PlaySectionMusic(PlaySectionType section)
     j = 0;
     track = cd_current_track();
 
+    if (section == PlaySectionStats) {
+	if (GameResult == GameVictory) {
+	    section = PlaySectionStatsVictory;
+	} else {
+	    section = PlaySectionStatsDefeat;
+	}
+    }
+
     for (i = 0; i < NumPlaySections; ++i) {
 	if (PlaySections[i].Type == section && (!PlaySections[i].Race || 
 		!(strcmp(PlaySections[i].Race, ThisPlayer->RaceName)))) {
@@ -503,8 +511,9 @@ global void PlaySectionMusic(PlaySectionType section)
 	    } else if (PlaySections[i].CDOrder == PlaySectionOrderRandom) {
     		do {
 		    newtrack = MyRand() % NumCDTracks;
-		} while ( ((newtrack << j) & PlaySections[i].CDTracks) && 
-		    (cd_is_audio(CDTrack) < 1) );
+		    printf("%d\n", newtrack);
+		} while ( !((1 << newtrack) & PlaySections[i].CDTracks) || 
+		    (cd_is_audio(newtrack) < 1) );
 	    }
 	}
 	if (newtrack) {
diff --git a/src/stratagus/script.cpp b/src/stratagus/script.cpp
index 578d2c137..92b7f24ad 100644
--- a/src/stratagus/script.cpp
+++ b/src/stratagus/script.cpp
@@ -907,13 +907,13 @@ global void SavePreferences(void)
     buf[0] = '\0';
     switch (CDMode) {
 	case CDModeAll:
-	    strcpy(buf, "all");
+	    strcpy(buf, "'all");
 	    break;
 	case CDModeRandom:
-	    strcpy(buf, "random");
+	    strcpy(buf, "'random");
 	    break;
 	case CDModeDefined:
-	    strcpy(buf, "defined");
+	    strcpy(buf, "'defined");
 	    break;
 	default:
 	    break;