 
             # Load texture
             @wfits.loadImage(band, arr, dataunit.width, dataunit.height)
-            dfs[index].resolve()
+            @dfs[band].resolve()
           )
         )
+  
+  # Initialize a WebFITS object
+  initWebFITS: =>
+    el = document.querySelector(@selector)
+    @wfits = new astro.WebFITS(el, @dimension)
+
+    unless @wfits.ctx?
+      alert 'Something went wrong initializing the context'
+  
+  # Call when all FITS received and WebFITS library is received
+  allChannelsReceived: (e) =>
+    console.log 'allChannelsReceived'
+    @dfs = undefined
+    
+    @computeNormalizedScales()
+    scales = @collection.getColorScales()
+    
+    @wfits.setAlpha(@defaultAlpha)
+    @wfits.setQ(@defaultQ)
+    @wfits.setScales.apply(@wfits, scales)
+    @wfits.setupControls()
+    @trigger 'swviewer:loaded'
+  
+  start: =>
+    console.log 'start'
   
   log10: (x) ->
     return Math.log(x) / Math.log(10)

  
  constructor: (selector) ->
    super selector
    # Default stretch
    @stretch = 'linear'
    
    # Run when the WebFITS API is received
    @on 'swviewer:ready', =>
      el = document.querySelector(@selector)
      @wfits = new astro.WebFITS(el, @dimension)
      unless @wfits.ctx?
        alert 'Something went wrong initializing the context'
      
      @unbind 'swviewer:ready'
  
  getApi: =>
    unless DataView?
      alert 'Sorry, your browser does not support features needed for this tool.'

    lib = if context? then 'gl' else 'canvas'
    url = "javascripts/webfits-#{lib}.js"
    $.getScript(url, =>
      @initWebFITS()
      @dfs.webfits.resolve()
    )
  
  # Request FITS files for each channel
  requestChannels: =>
    console.log 'requestChannels'
    
    subject = @opts.data[0]
    prefix  = subject.metadata.id
    
    # Set callback for when all channels and WebFITS Api received
    $.when.apply(null, _.values(@dfs))
      .done(@allChannelsReceived)
    
    for band, index in @bands
      do (band, index) =>
        path = "#{@source}#{prefix}_#{band}.fits.fz"
