index c234822..a8d9a68 100644
--- a/src/foreign-dl-lexer.l
+++ b/src/foreign-dl-lexer.l
@@ -75,6 +75,7 @@
 %option reentrant
 %option bison-bridge
 %option bison-locations
+%option case-insensitive
 
 digit      [0-9]
 whitespace [ \t\v\f]
@@ -85,12 +86,12 @@ whitespace [ \t\v\f]
 
 <*>\n\r|\r\n|\r|\n         { return NEWLINE; }
 
-[dD][lL]{whitespace}+      { return DL; }
-[nN]{whitespace}*[=]{whitespace}* {
+"DL"{whitespace}+      { return DL; }
+"N"{whitespace}*[=]{whitespace}* {
   return NEQ; }
 {digit}+                   { return NUM; }
 
-<INITIAL,LABELM>[dD][aA][tT][aA][:]        { 
+<INITIAL,LABELM>"Data:"        { 
   switch (yyextra->mode) { 
   case 0: BEGIN(FULLMATRIX); 
     break;
@@ -101,14 +102,14 @@ whitespace [ \t\v\f]
   } 
   return DATA; }
 
-[lL][aA][bB][eE][lL][sS]:  { BEGIN(LABELM); return LABELS; }
-<INITIAL,LABELM>[lL][aA][bB][eE][lL][sS]{whitespace}+[eE][mM][bB][eE][dD][dD][eE][dD]:?{whitespace}* {
+"Labels:"  { BEGIN(LABELM); return LABELS; }
+<INITIAL,LABELM>"Labels"{whitespace}+"Embedded":?{whitespace}* {
   return LABELSEMBEDDED; }
-[fF][oO][rR][mM][aA][tT]{whitespace}*[=]{whitespace}*[fF][uU][lL][lL][mM][aA][tT][rR][iI][xX]{whitespace}* {
+"Format"{whitespace}*[=]{whitespace}*"FullMatrix"{whitespace}* {
   yyextra->mode=0; return FORMATFULLMATRIX; }
-[fF][oO][rR][mM][aA][tT]{whitespace}*[=]{whitespace}*[eE][dD][gG][eE][lL][iI][sS][tT][1]{whitespace}* {
+"Format"{whitespace}*[=]{whitespace}*"EdgeList1"{whitespace}* {
   yyextra->mode=1; return FORMATEDGELIST1; }
-[fF][oO][rR][mM][aA][tT]{whitespace}*[=]{whitespace}*[nN][oO][dD][eE][lL][iI][sS][tT][1]{whitespace}* {
+"Format"{whitespace}*[=]{whitespace}*"NodeList1"{whitespace}* {
   yyextra->mode=2; return FORMATNODELIST1; }
 
 <LABELM>[, ]                               { /* eaten up */ }
diff --git a/src/foreign-dl-parser.y b/src/foreign-dl-parser.y
index 5c3bbd6..84ca43f 100644
--- a/src/foreign-dl-parser.y
+++ b/src/foreign-dl-parser.y
@@ -127,8 +127,8 @@ formfullmatrix:  FORMATFULLMATRIX newline fullmatrix {} | fullmatrix {} ;
 
 newline: | NEWLINE ;
 
-fullmatrix:   DATA newline fullmatrixdata { }
-            | LABELS newline labels newline DATA newline fullmatrixdata { }
+fullmatrix:   DATA fullmatrixdata { }
+            | LABELS newline labels newline DATA fullmatrixdata { }
             | LABELSEMBEDDED newline DATA newline labeledfullmatrixdata { }
 ;
 
@@ -139,7 +139,7 @@ labels: 	    {}		/* nothing, empty matrix */
 				  context); }
 ;
 
-fullmatrixdata: {} | fullmatrixdata zerooneseq NEWLINE {
+fullmatrixdata: {} | fullmatrixdata NEWLINE newline zerooneseq  {
   context->from += 1;
   context->to = 0;
  } ;
