     end
   end
 
-  defp upgrade_directives_supervisor(v1, v2, m, beam) do
+  defp upgrade_directives_supervisor(beam, v1, v2, m) do
     case beam_exports(beam, :sup_upgrade_notify, 2) do
       true ->
         [ { :update, m, :supervisor },

    end
  end

  def make_appup(application, v1, v1_props, v2, v2_path, v2_props) do
    add_mods = modules(v2_props) -- modules(v1_props)
    del_mods = modules(v1_props) -- modules(v2_props)

    { up_version_change, down_version_change } =
      case start_module(v2_props) do
        { :ok, start_mod, start_args } ->
          start_mod_beam_file = v2_path ++ '/ebin/' ++ atom_to_list(start_mod) ++ '.beam'
          {
            (lc {:ok, beam} inlist :file.read_file(start_mod_beam_file),
               d           inlist version_change(beam, v1, start_mod, start_args),
            do: d),
            (lc {:ok, beam} inlist :file.read_file(start_mod_beam_file),
               d           inlist version_change(beam, {:down, v1}, start_mod, start_args),
            do: d)
          }
        :undefined ->
          { [], [] }
      end

    up_directives =
      (lc m          inlist modules(v2_props) -- add_mods,
         beam_file   inlist (v2_path ++ '/ebin/' ++ atom_to_list(m) ++ '.beam'),
         {:ok, beam} inlist :file.read_file(beam_file),
         d           inlist upgrade_directives(v1, v2, m, beam),
      do: d)

    down_directives = 
      (lc m          inlist :lists.reverse(modules(v2_props) -- add_mods),
         beam_file   inlist (v2_path ++ '/ebin' ++ atom_to_list(m) ++ '.beam'),
         {:ok, beam} inlist :file.read_file(beam_file),
         d           inlist downgrade_directives(v1, v2, m, beam),
      do: d)
      
    appup =
      { v2,
        [ { v1,
            (lc m inlist add_mods, do: { :add_module, m })
            ++ up_directives
            ++ up_version_change
            ++ (lc m inlist del_mods, do: { :delete_module, m })
          }
        ],
        [ { v1,
            (lc m inlist :lists.reverse(del_mods), do: { :add_module, m })
            ++ down_version_change
            ++ down_directives


  defp vsn(props) do
    { :value, { :vsn, vsn } } = :lists.keysearch(:vsn, 1, props)
    vsn |> from_char_list!
  end

  defp has_element(attr, key, elem) do
