     relative = []
     libraryManager.pathsCommonPrefix files, relative, basePath
     map = {}
-    for i in [0..files.length]
+    for i in [0..files.length-1]
       map[relative[i]] = files[i]
     return map
 
   # Compile current project in the cloud
+  # when updating arguments here, also update the event emitter above
   compileCloud: (thenFlash=null, files=null, rootPath=null) -> @loginRequired =>
     if !@canCompileNow
       return

          example.buildFiles(files)
            .then =>
              console.log('compiling example files', files)
              @compileCloud true, files.map, files.basePath

  flashCloudFile: (event) ->
    @flashCloud event.target.dataset.path

  flashCloudExampleFile: (event) ->
    file = event.target.dataset.path
    @flashCloudExample file

  # Show serial monitor panel
  showSerialMonitor: ->

      @identifyCore(event.port)

    @emitter.on "#{@packageName()}:compile-cloud", (event) =>
      @compileCloud(event.thenFlash, event.files, event.rootPath)

    @emitter.on "#{@packageName()}:flash-cloud", (event) =>
      @flashCloud(event.firmware)
