                   (Flow.Async.iterate tasks) go
 
             runFlow = (packName, flowName, go) ->
-              doFlow = (flowName, excludeFlowNames) ->
-                for f in excludeFlowNames
+              doFlow = (flowName, excludeFlowsNames) ->
+                for f in excludeFlowsNames
                   return false if flowName is f
                 true
 
-              if doFlow flowName, window._excludeFlowNames
+              if doFlow flowName, window._excludeFlowsNames
                 flowTitle = "#{packName} - #{flowName}"
                 window._phantom_test_summary_[flowTitle] = 'FAILED'
                 console.log "Fetching flow document: #{packName} - #{flowName}..."

parseOpts = (args) ->
  console.log "Using args #{args.join ' '}"
  i = 0
  while i < args.length
    if args[i] == "--host"
      i = i + 1
      if i > args.length then printUsageAndExit "Unknown argument: #{args[i]}"
      hostname = args[i]
    else if args[i] == "--timeout"
      i = i + 1
      if i > args.length then printUsageAndExit "Unknown argument: #{args[i]}"
      timeout = args[i]
    else if args[i] == "--packs"
      i = i + 1
      if i > args.length then printUsageAndExit "Unknown argument: #{args[i]}"
      packs = args[i]
    else if args[i] == "--perf"
      perf = true
      i = i + 1
      if i > args.length then printUsageAndExit "Unknown argument: #{args[i]}"
      date = args[i]
      i = i + 1
      if i > args.length then printUsageAndExit "Unknown argument: #{args[i]}"
      buildId = args[i]
      i = i + 1
      if i > args.length then printUsageAndExit "Unknown argument: #{args[i]}"
      gitHash = args[i]
      i = i + 1
      if i > args.length then printUsageAndExit "Unknown argument: #{args[i]}"
      gitBranch = args[i]
      i = i + 1
      if i > args.length then printUsageAndExit "Unknown argument: #{args[i]}"
      ncpu = args[i]
      i = i + 1
      if i > args.length then printUsageAndExit "Unknown argument: #{args[i]}"
      os = args[i]
      i = i + 1
      if i > args.length then printUsageAndExit "Unknown argument: #{args[i]}"
      jobName = args[i]
      i = i + 1
      if i > args.length then printUsageAndExit "Unknown argument: #{args[i]}"
      outputDir = args[i]
    else if args[i] == "--excludeFlows"
      i = i + 1
      if i > args.length then printUsageAndExit "Unknown argument: #{args[i]}"
      excludeFlows = args[i]
    else
      printUsageAndExit "Unknown argument: #{args[i]}"
    i = i + 1

parseOpts system.args[1..]

if hostname == null then hostname = 'localhost:54321'
console.log "PHANTOM: Using #{hostname}"

timeout = if timeout == null then 3600000 else 1000 * parseInt timeout, 10
console.log "PHANTOM: Using timeout #{timeout}ms"

packNames = if packs == null then ['examples'] else packs.split ':'
console.log "PHANTOM: Using packs:"
for packName in packNames
  console.log "PHANTOM: #{packName}"

excludeFlowNames = if excludeFlows == null then [] else excludeFlows.split ';'
console.log "PHANTOM: Excluding flows:"
for excludeFlowName in excludeFlowNames
  console.log "PHANTOM: #{excludeFlowName}"

page = webpage.create()

if perf
  console.log "PHANTOM: Performance of individual tests will be recorded in perf.csv in output directory: #{outputDir}."
  page._outputDir = outputDir

page.onResourceError = ({ url, errorString }) ->
  console.log "BROWSER: *** RESOURCE ERROR *** #{url}: #{errorString}"

                console.log 'Finished running all packs!'
              window._phantom_exit_ = yes
            no
        packNames, opts['date'], opts['buildId'], opts['gitHash'], opts['gitBranch'], hostname, opts['ncpu'], \
        opts['os'], opts['jobName'], opts['perf'], excludeFlowsNames
      )

    printErrors = (errors, prefix='') ->
