  Save bounds of main window to storage.
 ###
 saveWindowBounds = (callback) ->
-  return if not mainWindow?
-  bound = mainWindow.getContentBounds()
+  return if not _mainWindow?
+  bound = _mainWindow.getContentBounds()
   # console.log(bound)
   storage.set BOUND, bound, (err) ->
     if err

  if debug
    require('electron-debug')({ showDevTools: true })

# prevent window being garbage collected
mainWindow = undefined

LOGIN = "login"
BOUND = "bound"
PROXY_AUTH = "proxy_auth"
DEFAULT_BOUNDS = { width: 250, height: 550 }

_bound = {}
_event = {}
_triedSavedAccount = false

###*
 On closed listener.


app.on 'activate', ->
  # console.log('activate')
  return if _mainWindow
  getWindowBounds (bound) ->
    _mainWindow = createMainWindow(bound)
  return

app.on 'ready', ->
  # console.log('ready')
  Menu.setApplicationMenu(Menu.buildFromTemplate(template))
  getWindowBounds (bound) ->
    _mainWindow = createMainWindow(bound)
  return

app.on 'login', (event, webContents, request, authInfo, callback) ->
