-mkEl = (name) -> (id, domContent) ->
-  wrapper = document.createElement(name)
-  id && wrapper.id = id
-  wrapper.appendChild(domContent)
-  wrapper
+mkEl = (name, id, content) ->
+  el = document.createElement(name)
+  id && el.id = id
+  content && el.appendChild(content)
+  el
 
-mkDiv = mkEl 'div'
 
 window.FACTLINK_START_LOADER = ->
   if window.FACTLINK_LOADED

    return
  window.FACTLINK_LOADED = true

  #### Create iframe so jslib's namespace (window) doesn't collide with any content window.
  jslib_jail_iframe = document.createElement('iframe')
  jslib_jail_iframe.style.display = 'block'
  jslib_jail_iframe.style.border = '0px solid transparent'
  jslib_jail_iframe.id = 'factlink-iframe'

  # Wrappers for increased CSS specificity
  outerWrapperEl =
    mkDiv 'fl-wrapper-1',
      mkDiv 'fl-wrapper-2',
        mkDiv 'fl-wrapper-3',
          mkDiv 'fl', jslib_jail_iframe

  # Keep in sync with #fl-wrapper-1 in basic.less
  outerWrapperEl.style.visibility = 'hidden'; # Prevent showing stuff when css is not loaded yet
  outerWrapperEl.style.position = 'absolute'; # Prevent reflowing of the page

  document.body.appendChild outerWrapperEl



  window.FACTLINK_ON_CORE_LOAD = ->
    # This seems to be necessary, don't understand entirely why
#    window.FACTLINK.easyXDM = jslib_jail_iframe.contentWindow.Factlink.easyXDM

    for methodCall in storedMethodCalls
      jslib_jail_iframe.contentWindow.Factlink[methodCall.name](methodCall.arguments...)
    storedMethodCalls = []

  jslib_jail_iframe.contentWindow.FactlinkConfig = window.FactlinkConfig
  #### Load iframe with script tag
  jslib_jail_doc = jslib_jail_iframe.contentWindow.document

