   constructor: (armored_key) ->
     @load_key(armored_key)
 
-  ready: ->
+  setup: ->
       $("form[data-encrypted-form]").each (index, element) =>
         $(element).submit((e)=>
           @submit_handler(e, element)


  submit_handler: (e, form) ->
    e.preventDefault()
    values = @get_values(form)
    single_defer = $.Deferred()
    group_defer = $.Deferred()
    @single_encryption(form, values, (result) ->
      single_defer.resolve()
    )
    $.when(single_defer).done(() =>
      @group_encryption(form, values, (result) ->
        group_defer.resolve()
      )
    )
    $.when(single_defer, group_defer).done(() =>
      @reinsert_values values
      form.submit()
    )

  get_values: (form) ->
    return $(form).serializeArray()

  single_encryption: (form, values, callback) ->
    names_to_encrypt = @find_names_for(form, "*[data-encrypt]")
    defers = []
    @encrypt_requested_fields(values, names_to_encrypt, defers)
    $.when.apply($, defers).done(() -> # Spat defers to param list with apply
      callback(values)
    )

  find_names_for: (root, selector) ->

      else
        callback(result_string)

  reinsert_values: (form_data) ->
    for i in [0..form_data.length-1]
      $("*[name='#{form_data[i].name}']").val(form_data[i].value)

  group_encryption: (form, form_data, callback) ->
    elements = $("*[data-encrypt-source]")
    encryption_source_names = @find_names_for(form, elements)
    if encryption_source_names.length
      buffer = @collect_sources(elements)
      @wipe_source_fields(form_data, encryption_source_names)
      @write_target(buffer, form_data, callback)
    else
      callback()

