     if @positions.hasOwnProperty name
       @variables[@positions[name]].type = type
     else
-      @positions[name] = @variables.length
-      @variables.push {name, type}
+      @positions[name] = -1 + @variables.push {name, type}
+    this
 
   # Create a new garbage level
   startLevel: ->
     @garbage.push []
+    this
 
   # Return to the previous garbage level and erase referenced temporary
   # variables in current level from scope.
   endLevel: ->
-    vars = @variables
-    for garbage in @garbage.pop() when @type(garbage) is 'var'
-      @setVar garbage, 'reuse'
+    @setVar name, 'reuse' for name in @garbage.pop() when @type(name) is 'var'
+    this
 
   # Look up a variable name in lexical scope, and declare it if it does not
   # already exist.

    !!@parent?.check name

  # Generate a temporary variable name at the given index.
  temporary: (type, index) ->
    if type.length > 1
      '_' + type + if index > 1 then index else ''
    else
      '_' + (index + parseInt type, 36).toString(36).replace /\d/g, 'a'
  
  # Gets the type of a variable.
  type: (name) ->

    @variables = [{name: 'arguments', type: 'arguments'}]
    @positions = {}
    if @parent
      {@garbage} = @parent
    else
      @garbage   = []
      Scope.root = this
