diff --git a/mode/haskell/haskell.js b/mode/haskell/haskell.js
index 107885c20fc804c1157cf3c54308a5c6154abf2e..759ff602c974fda2d48613477d4f8c464b838e05 100644
--- a/mode/haskell/haskell.js
+++ b/mode/haskell/haskell.js
@@ -114,7 +114,7 @@ CodeMirror.defineMode("haskell", function(cmCfg, modeCfg) {
     return function(source, setState) {
       var currNest = nest;
       while (!source.eol()) {
-        ch = source.next();
+        var ch = source.next();
         if (ch == '{' && source.eat('-')) {
           ++currNest;
         }
diff --git a/mode/rst/rst.js b/mode/rst/rst.js
index 731fcab403afd0cce710c4a1b0ebe43a9e81f9f9..8dd5f281b82b2d6d28ef3df99f4f7782a635e572 100644
--- a/mode/rst/rst.js
+++ b/mode/rst/rst.js
@@ -193,7 +193,7 @@ CodeMirror.defineMode('rst', function(config, options) {
                         ch: orig,               // inline() has to know what to search for
                         wide: wide,             // are we looking for `ch` or `chch`
                         prev: null,             // terminator must not be preceeded with whitespace
-                        token: token,           // I don't want to recompute this all the time
+                        token: token            // I don't want to recompute this all the time
                     });
 
                     return token;
diff --git a/mode/stex/stex.js b/mode/stex/stex.js
index 10e0d6cada2decb43d36d2f1cb8cac2367073ab9..3106e3be0c74a8929072f47df708d72975f613ce 100644
--- a/mode/stex/stex.js
+++ b/mode/stex/stex.js
@@ -24,7 +24,7 @@ CodeMirror.defineMode("stex", function(cmCfg, modeCfg)
     }
 
     function applyMostPowerful(state) {
-      context = state.cmdState;
+      var context = state.cmdState;
       for (var i = context.length - 1; i >= 0; i--) {
 	  var plug = context[i];
 	  if (plug.name=="DEFAULT")
@@ -83,7 +83,7 @@ CodeMirror.defineMode("stex", function(cmCfg, modeCfg)
 
     function normal(source, state) {
 	if (source.match(/^\\[a-z]+/)) {
-	    cmdName = source.current();
+	    var cmdName = source.current();
 	    cmdName = cmdName.substr(1, cmdName.length-1);
 	    var plug = plugins[cmdName];
 	    if (typeof(plug) == 'undefined') {
@@ -133,8 +133,8 @@ CodeMirror.defineMode("stex", function(cmCfg, modeCfg)
     function beginParams(source, state) {
 	var ch = source.peek();
 	if (ch == '{' || ch == '[') {
-	   lastPlug = peekCommand(state);
-	   style = lastPlug.openBracket(ch);
+	   var lastPlug = peekCommand(state);
+	   var style = lastPlug.openBracket(ch);
 	   source.eat(ch);
 	   setState(state, normal);
 	   return "stex-bracket";