 _ = require 'underscore'
 {BrowserWindow} = require 'electron'
 global.windows = windows = []
+global.windowsIndex = windowsIndex = {}
 
 forceClose = false
 state = []  # Window state before hide

        'web-security': false
        'plugins': true
    current = new BrowserWindow options
    # Default menu in v0.27.3
    if process.versions['electron'] >= '0.27.3'
      current.setMenu options.menu || null

    # Close window really
    if options.realClose
      current.on 'closed', (e) ->
        if options.indexName?
          delete windowsIndex[options.indexName]
        idx = _.indexOf windows, current
        windows.splice idx, 1
    else if options.forceMinimize
