     end
   end
 
-  defp downgrade_directives(v1, v2, m, beam) do
+  defp downgrade_directives(beam, v1, v2, m) do
     case is_supervisor(beam) do
       true ->
-        downgrade_directives_supervisor(v1, v2, m, beam)
+        downgrade_directives_supervisor(beam, v1, v2, m)
       false ->
         case has_code_change(beam) do
           true  -> [ { :update, m, :infinity, { :advanced, [] }, :brutal_purge, :brutal_purge, [] } ]

    end
  end

  defp downgrade_directives_supervisor(v1, v2, m, beam) do
    case beam_exports(beam, :sup_downgrade_notify, 2) do
      true ->
        [ {

    end
  end

  defp 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 
            |> Path.join("/ebin/")
            |> Path.join(atom_to_binary(start_mod) <> ".beam")
          { start_mod_beam_file |> File.read! |> version_change(v1, start_mod, start_args),
            start_mod_beam_file |> File.read! |> version_change({:down, v1}, start_mod, start_args) }
        :undefined ->
          { [], [] }
      end

    up_directives =
      (modules(v2_props) -- add_mods) |> Enum.map(fn module ->
        (v2_path <> "/ebin/" <> atom_to_binary(module) <> ".beam")
        |> File.read!
        |> upgrade_directives(v1, v2, module)
      end)

    down_directives = 
      Enum.reverse(modules(v2_props) -- add_mods) |> Enum.map(fn module ->
        (v2_path <> "/ebin/" <> atom_to_binary(module) <> ".beam")
        |> File.read!
        |> downgrade_directives(v1, v2, module)
      end)
      
    appup =
      { v2 |> to_char_list!,
        [ { v1 |> to_char_list!,
            (lc m inlist add_mods, do: { :add_module, m })
            ++ up_directives
            ++ up_version_change
            ++ (lc m inlist del_mods, do: { :delete_module, m })
          }
        ],
        [ { v1 |> to_char_list!,
            (lc m inlist :lists.reverse(del_mods), do: { :add_module, m })
            ++ down_version_change
            ++ down_directives
