             OK: -> installPython()
             Cancel: -> window.alert('Please install Python (https://www.python.org/downloads/) and restart Atom to enable the WakaTime plugin.')
     )
+    cleanupOnUninstall()
     setupConfig()
     setupEventHandlers()
-    console.log 'WakaTime v'+VERSION+' loaded.'
-
-lastHeartbeat = 0
-lastFile = ''
+    console.log 'WakaTime v'+packageVersion+' loaded.'
 
 enoughTimePassed = (time) ->
   return lastHeartbeat + 120000 < time


extractCLI = (zipFile, callback) ->
  console.log 'Extracting wakatime-master.zip file...'
  if fs.existsSync(__dirname + path.sep + 'wakatime-master')
    try
      rimraf(__dirname + path.sep + 'wakatime-master', ->
        unzip(zipFile, __dirname, callback)
      )
    catch e
      console.warn e
      unzip(zipFile, __dirname, callback)
  else
    unzip(zipFile, __dirname, callback)

downloadFile = (url, outputFile, callback) ->
  r = request(url)


latestCLIVersion = '4.1.0'

packageVersion = null
unloadHandler = null
lastHeartbeat = 0
lastFile = ''

module.exports =

  activate: (state) ->
    packageVersion = atom.packages.getLoadedPackage('wakatime').metadata.version

    if not isCLIInstalled()
      installCLI(->
