diff --git a/src/main/java/org/sablecc/sablecc/GenLexer.java b/src/main/java/org/sablecc/sablecc/GenLexer.java
index d4b8e53c17623bc604ce6be1211e33992128fd30..03f2e07418149e0cb8520354d93427c675bce1be 100644
--- a/src/main/java/org/sablecc/sablecc/GenLexer.java
+++ b/src/main/java/org/sablecc/sablecc/GenLexer.java
@@ -286,18 +286,14 @@ public class GenLexer extends AnalysisAdapter
 
       if(ids.stateList.size() > 0)
       {
-        for(ListIterator<String> i = ids.stateList.listIterator(); i.hasNext();)
+        for (String s : ids.stateList)
         {
-          String s = i.next();
-
-          macros.apply(file, "LexerStateBody",
-                       new String[] {s, "" + i.previousIndex()});
+          macros.apply(file, "LexerStateBody", new String[] {s});
         }
       }
       else
       {
-        macros.apply(file, "LexerStateBody",
-                     new String[] {"INITIAL", "" + 0});
+        macros.apply(file, "LexerStateBody", new String[] {"INITIAL"});
       }
 
       macros.apply(file, "LexerStateTail");
diff --git a/src/main/java/org/sablecc/sablecc/lexer/Lexer.java b/src/main/java/org/sablecc/sablecc/lexer/Lexer.java
index 78892eb19ad9732a3e371714804810a3bc0e139b..9a4ac88cf2fd600b260126cf2d6e05fc0fe772e1 100644
--- a/src/main/java/org/sablecc/sablecc/lexer/Lexer.java
+++ b/src/main/java/org/sablecc/sablecc/lexer/Lexer.java
@@ -110,8 +110,8 @@ public class Lexer implements ITokenListContainer
         int accept_pos = -1;
         int accept_line = -1;
 
-        int[][][] gotoTable = Lexer.gotoTable[this.state.id()];
-        int[] accept = Lexer.accept[this.state.id()];
+        int[][][] gotoTable = Lexer.gotoTable[this.state.ordinal()];
+        int[] accept = Lexer.accept[this.state.ordinal()];
         this.text.setLength(0);
 
         while(true)
@@ -212,7 +212,7 @@ public class Lexer implements ITokenListContainer
                             pushBack(accept_length);
                             this.pos = accept_pos;
                             this.line = accept_line;
-                            switch(state.id())
+                            switch(state.ordinal())
                             {
                                 case 1: state = State.PACKAGE; break;
                             }
@@ -226,7 +226,7 @@ public class Lexer implements ITokenListContainer
                             pushBack(accept_length);
                             this.pos = accept_pos;
                             this.line = accept_line;
-                            switch(state.id())
+                            switch(state.ordinal())
                             {
                                 case 0: state = State.PACKAGE; break;
                             }
@@ -380,7 +380,7 @@ public class Lexer implements ITokenListContainer
                             pushBack(accept_length);
                             this.pos = accept_pos;
                             this.line = accept_line;
-                            switch(state.id())
+                            switch(state.ordinal())
                             {
                                 case 0: state = State.NORMAL; break;
                                 case 1: state = State.NORMAL; break;
@@ -995,21 +995,15 @@ public class Lexer implements ITokenListContainer
 
     };*/
 
-    public static class State
+    public enum State
     {
-        public final static State NORMAL = new State(0);
-        public final static State PACKAGE = new State(1);
-
-        private int id;
-
-        private State(int id)
-        {
-            this.id = id;
-        }
+        NORMAL,
+        PACKAGE,
+        ;
 
         public int id()
         {
-            return this.id;
+            return this.ordinal();
         }
     }
 
diff --git a/src/main/resources/org/sablecc/sablecc/lexer.txt b/src/main/resources/org/sablecc/sablecc/lexer.txt
index 2b41b6c1537f1b42aebb4b0a2e2a32b290a6ea11..44e22aeb2d9d6f4132d0d1ded45a690adbd466fa 100644
--- a/src/main/resources/org/sablecc/sablecc/lexer.txt
+++ b/src/main/resources/org/sablecc/sablecc/lexer.txt
@@ -134,8 +134,8 @@ public class Lexer implements ITokenListContainer
         int accept_pos = -1;
         int accept_line = -1;
 
-        int[][][] gotoTable = Lexer.gotoTable[this.state.id()];
-        int[] accept = Lexer.accept[this.state.id()];
+        int[][][] gotoTable = Lexer.gotoTable[this.state.ordinal()];
+        int[] accept = Lexer.accept[this.state.ordinal()];
         this.text.setLength(0);
 
         while(true)
@@ -256,7 +256,7 @@ Macro:LexerFixedToken
 $
 
 Macro:TokenSwitchHeader
-                            switch(state.id())
+                            switch(state.ordinal())
                             {
 
 $
@@ -382,28 +382,22 @@ Macro:LexerAcceptTail
 $
 
 Macro:LexerStateHeader
-    public static class State
+    public enum State
     {
 
 $
 
 Macro:LexerStateBody
-        public final static State $0$ = new State($1$);
+        $0$,
 
 $
 
 Macro:LexerStateTail
-
-        private int id;
-
-        private State(int id)
-        {
-            this.id = id;
-        }
+        ;
 
         public int id()
         {
-            return this.id;
+            return this.ordinal();
         }
     }