   window.removeEventListener 'keydown', onkey
   window.clearInterval autosaver
 
-onkey = (event) ->
-  if retro.player and settings.keys.hasOwnProperty event.which
-    pressed = event.type == 'keydown'
-    retro.player.inputs[0].buttons[settings.keys[event.which]] ?= {}
-    retro.player.inputs[0].buttons[settings.keys[event.which]].pressed = pressed
-    event.preventDefault()
-
-init = (rom, extension, save) ->
-  stop() if retro.running
-  Promise.resolve cores[settings.extensions[extension]]
-  .then (core) ->
-    retro.core = core
-    core.load_game rom if rom
-    core.unserialize new Uint8Array save if save?
-    core.set_input_poll ->
-      gamepads = navigator.getGamepads() if navigator.getGamepads
-      retro.player.inputs = gamepads if gamepads and gamepads[0]
-    retro.player.inputs = [
-      buttons: {}
-    ]
-    window.addEventListener 'keydown', onkey
-    window.addEventListener 'keyup', onkey
-    retro
-
 play = (rom, extension) ->
   Promise.resolve()
   .then ->
-    throw new Error 'no rom!' if not rom
+    throw 'no rom!' if not rom
     retro.md5 = sparkmd5.ArrayBuffer.hash rom
-    localForage.getItem retro.md5
-    .then (save) ->
-      init rom, extension, save
-      .then (retro) ->
-        autosaver = setInterval ->
-          localForage.setItem retro.md5, new Uint8Array retro.core.serialize()
-        , 1000
-        retro.start()
+    Promise.all([
+      System.import settings.extensions[extension]
+      localForage.getItem retro.md5
+    ]).then ([core, save]) ->
+      stop() if retro.running
+      retro.core = core
+      core.load_game rom if rom
+      core.unserialize new Uint8Array save if save?
+      core.set_input_poll ->
+        gamepads = navigator.getGamepads() if navigator.getGamepads
+        retro.player.inputs = gamepads if gamepads and gamepads[0]
+      retro.player.inputs = [
+        buttons: {}
+      ]
+      autosaver = setInterval ->
+        localForage.setItem retro.md5, new Uint8Array core.serialize()
+      , 1000
+      window.addEventListener 'keydown', onkey
+      window.addEventListener 'keyup', onkey
+      retro.start()
 
 loadData = (filename, buffer) ->
   draghint.classList.add 'hidden'
   extension = utils.getExtension filename
   rom = null
-  tracker.sendEvent 'play', filename
   if extension is 'zip'
     zip = new JSZip buffer
     for file in zip.file /.*/ # any way to predict name of file?

  play rom, extension
  .catch (e) ->
    console.error e
    location.reload() # hacky but a fix

load = (file) ->
  return if not file instanceof Blob
  draghint.classList.add 'hidden'
  readFile file
  .then (buffer) ->
    loadData file.name, buffer

window.addEventListener 'drop', (event) ->
  return if draghint.classList.contains 'hidden'

window.retro = retro = document.createElement 'canvas', 'x-game'
document.body.appendChild retro

onkey = (event) ->
  if retro.player and settings.keys.hasOwnProperty event.which
    pressed = event.type == 'keydown'
    retro.player.inputs[0].buttons[settings.keys[event.which]] ?= {}
    retro.player.inputs[0].buttons[settings.keys[event.which]].pressed = pressed
    event.preventDefault()

autosaver = 0

