diff --git a/cronscript b/cronscript
index e7a4aae..ded6349 100755
--- a/cronscript
+++ b/cronscript
@@ -29,7 +29,7 @@ if [ $(echo "$LANGSEL" | wc -l) -eq 2 ]; then
 else
 	# Selected language is the last in the file
 	LANG="$LANGSEL"
-	NEXTLANG="$(egrep -v "^[[:space:]]*(#.*)?$" langlist | head -n1)"
+	NEXTLANG="$(egrep -v '^[[:space:]]*(#.*)?$' langlist | head -n1)"
 fi
 
 LOCALE=$(echo "$LANG" | cut -d: -f1)
@@ -39,7 +39,7 @@ GRUBLINE=$(echo "$LANG" | cut -d: -f4)
 sed -i "s/LANGNAME \".*\"/LANGNAME \"$LANGNAME\"/" preseed_early
 
 sed -i "s/locale=.*$/locale=$LOCALE $GRUBLINE/
-        s/^set default=.*$/set default=\"2\"/" $ROOT/boot/grub/grub.cfg
+        s/^\([[:space:]]*\)set default=\"[[:digit:]]*\"$/\1set default=\"2\"/" $ROOT/boot/grub/grub.cfg
 
 # Comment out the next three lines if you don't want the language to change
 N_LOCALE=$(echo "$NEXTLANG" | cut -d: -f1)
diff --git a/preseed_late b/preseed_late
index 326e4ac..e70889a 100755
--- a/preseed_late
+++ b/preseed_late
@@ -11,7 +11,7 @@ echo "@reboot	root	/root/cronscript; reboot" >>/target/etc/crontab
 
 mount /dev/discs/disc0/part1 /hd-media -o remount,rw
 
-sed -i "s/^set default=.*$/set default=\"3\"/" /hd-media/boot/grub/grub.cfg
+sed -i "s/^\([[:space:]]*\)set default=\"[[:digit:]]*\"$/\1set default=\"3\"/" /hd-media/boot/grub/grub.cfg
 
 if [ -d /target/etc/gdm3 ] ; then
 	# Enable automatic login (chroot because of bug in busybox sed)