         message: 'Error parsing root scope'
         cause: error
 
-removeHoistedDeclarations = (context) ->
-  (rootScope, program, go) ->
-    try
-      traverseJavascript null, null, program, (parent, key, node) ->
-        if node.type is 'VariableDeclaration'		
-          declarations = node.declarations.filter (declaration) ->		
-            declaration.type is 'VariableDeclarator' and declaration.id.type is 'Identifier' and not rootScope[declaration.id.name]		
-          if declarations.length is 0
-            # purge this node so that escodegen doesn't fail		
-            deleteAstNode parent, key		
-          else		
-            # replace with cleaned-up declarations
-            node.declarations = declarations
-      go null, rootScope, program
-    catch error
-      go
-        message: 'Error rewriting javascript'
-        cause: error
-
-
-rewriteJavascript = (context) ->
-  (rootScope, program, go) ->
-    try
-      traverseJavascriptScoped [ rootScope ], rootScope, null, null, program, (globalScope, parent, key, node) ->
-        if node.type is 'Identifier'
-          return if parent.type is 'VariableDeclarator' and key is 'id' # ignore var declarations
-          return if key is 'property' # ignore members
-          return unless identifier = globalScope[node.name]
-
-          # qualify identifier with 'context'
-          parent[key] =
-            type: 'MemberExpression'
-            computed: no
-            object:
-              type: 'Identifier'
-              name: identifier.object
-            property:
-              type: 'Identifier'
-              name: identifier.name
-      go null, program
-    catch error
-      go
-        message: 'Error rewriting javascript'
-        cause: error
-
-
-rewriteJavascript__old = (_context) ->
-  (program, go) ->
-    topLevelDeclarations = parseDeclarations program.body[0].expression.right.callee.body
-    for name of _context when name isnt '_routines_' and name isnt '_results_' #XXX pass routines and results as params, keep context clean
-      topLevelDeclarations[name] =
-        name: name
-        object: 'context'
-    
-    try
-      traverseJavascript null, null, program, (parent, i, node) ->
-        # remove hoisted vars		
-        if node.type is 'VariableDeclaration'		
-          declarations = node.declarations.filter (declaration) ->		
-            declaration.type is 'VariableDeclarator' and declaration.id.type is 'Identifier' and not topLevelDeclarations[declaration.id.name]		
-          if declarations.length is 0
-            # purge this node so that escodegen doesn't fail		
-            deleteAstNode parent, i		
-          else		
-            # replace with cleaned-up declarations
-            node.declarations = declarations
-
-        #
-        # XXX Nasty hack - re-implement
-        #
-        # bail out if imported identifiers are used as function params
-        else if node.type is 'FunctionExpression' or node.type is 'FunctionDeclaration'
-          for param in node.params when param.type is 'MemberExpression'
-            throw new Error "Function has a formal parameter name-clash with identifier '#{param.object.name}'. Correct this and try again." 
-
-        # replace identifier with qualified name
-        else if node.type is 'Identifier'
-          return if parent.type is 'VariableDeclarator' and i is 'id' # ignore var declarations
-          return if i is 'property' # ignore members
-          return unless identifier = topLevelDeclarations[node.name]
-
-          parent[i] =
-            type: 'MemberExpression'
-            computed: no
-            object:
-              type: 'Identifier'
-              name: identifier.object
-            property:
-              type: 'Identifier'
-              name: identifier.name
-
-    catch error
-      return go
-        message: 'Error rewriting javascript'
-        cause: error
-
+#TODO DO NOT call this for raw javascript:
+# Require alternate strategy: 
+#   Declarations with 'var' need to be local to the cell.
+#   Undeclared identifiers are assumed to be global.
+#   'use strict' should be unsupported.
+removeHoistedDeclarations = (rootScope, program, go) ->
+  try
+    traverseJavascript null, null, program, (parent, key, node) ->
+      if node.type is 'VariableDeclaration'		
+        declarations = node.declarations.filter (declaration) ->		
+          declaration.type is 'VariableDeclarator' and declaration.id.type is 'Identifier' and not rootScope[declaration.id.name]		
+        if declarations.length is 0
+          # purge this node so that escodegen doesn't fail		
+          deleteAstNode parent, key		
+        else		
+          # replace with cleaned-up declarations
+          node.declarations = declarations
+    go null, rootScope, program
+  catch error
+    go
+      message: 'Error rewriting javascript'
+      cause: error
+
+
+rewriteJavascript = (rootScope, program, go) ->
+  try
+    traverseJavascriptScoped [ rootScope ], rootScope, null, null, program, (globalScope, parent, key, node) ->
+      if node.type is 'Identifier'
+        return if parent.type is 'VariableDeclarator' and key is 'id' # ignore var declarations
+        return if key is 'property' # ignore members
+        return unless identifier = globalScope[node.name]
+
+        # qualify identifier with '_h2o_context_'
+        parent[key] =
+          type: 'MemberExpression'
+          computed: no
+          object:
+            type: 'Identifier'
+            name: identifier.object
+          property:
+            type: 'Identifier'
+            name: identifier.name
     go null, program
+  catch error
+    go
+      message: 'Error rewriting javascript'
+      cause: error
 
 generateJavascript = (program, go) ->
   try

    block = map lines, (line) -> '  ' + line

    # enclose in execute-immediate closure
    block.unshift "context._results_['#{guid}'] = do ->"

    # join and proceed
    go null, join block, '\n'

      cause: error

parseJavascript = (js, go) ->
  try
    go null, esprima.parse js
  catch error
