 			// this function avoids unnecessary function calls by keeping its own call stack rather than using recursion.
 			var wrapperFunction:Function = function(...args):*
 			{
-				// reset local symbol table each time the function is called
+				builtInSymbolTable['this'] = this;
+				
+				// reset local symbol table each time the function is called so it behaves the same way each time.
 				for (symbolName in localSymbolTable)
-					localSymbolTable[symbolName] = undefined;
-				
-				builtInSymbolTable['this'] = this;
-				builtInSymbolTable['arguments'] = args;
+					delete localSymbolTable[symbolName];
+				
 				// make function parameters available under the specified parameter names
+				localSymbolTable['arguments'] = args;
 				if (paramNames)
 					for (i = 0; i < paramNames.length; i++)
-						builtInSymbolTable[paramNames[i] as String] = args.length > i ? args[i] : paramDefaults[i];
+						localSymbolTable[paramNames[i] as String] = i < args.length ? args[i] : paramDefaults[i];
 				
 				if (useThisScope)
 					allSymbolTables[THIS_SYMBOL_TABLE_INDEX] = this;

				}
				else if (escapeIndex < bracketIndex) // handle '\'
				{
					// look up escaped character
					var c:String = input.charAt(escapeIndex + 1);
					
					//TODO: octal and hex escape sequences
					
					c = DECODE_LOOKUP[c] || c;
					output += input.substring(searchIndex, escapeIndex) + c;
					// skip over escape sequence
					searchIndex = escapeIndex + 2;
				}
				else if (bracketIndex < escapeIndex) // handle '{'
				{


			const builtInSymbolTable:Object = {};
			const localSymbolTable:Object = {};
			// set up Array of symbol tables in the correct scope order: built-in, local, params, this, global
			const allSymbolTables:Array = [
				builtInSymbolTable,
				localSymbolTable,
				symbolTable,
				null/*this*/,
				constants
			];
