   # Gets all applications which are part of the release application tree
   def get_apps(%Release{name: name, applications: apps} = release) do
     children = get_apps(App.new(name), [])
-    base_apps = Enum.reduce(apps, children, fn
-      _, {:error, reason} ->
-        {:error, {:apps, reason}}
-      {a, start_type}, acc ->
-        cond do
-          App.valid_start_type?(start_type) ->
-            case Enum.any?(acc, fn %App{name: ^a} -> true; _ -> false end) do
-              true  ->
+    base_apps =
+      Enum.reduce(apps, children, fn
+        _, {:error, reason} ->
+          {:error, {:apps, reason}}
+        {a, start_type}, acc ->
+          cond do
+            App.valid_start_type?(start_type) ->
+              if Enum.any?(acc, fn %App{name: app} -> a == app end) do
                 # Override start type
                 Enum.map(acc, fn %App{name: ^a} = app -> %{app | start_type: start_type}; app -> app end)
-              false ->
+              else
                 get_apps(App.new(a, start_type), acc)
-            end
-          :else ->
-            {:error, {:apps, {:invalid_start_type, a, start_type}}}
-        end
-      a, acc when is_atom(a) ->
-        case Enum.any?(acc, fn %App{name: ^a} -> true; _ -> false end) do
-          true  -> acc
-          false -> get_apps(App.new(a), acc)
-        end
-    end)
+              end
+            :else ->
+              {:error, {:apps, {:invalid_start_type, a, start_type}}}
+          end
+        a, acc when is_atom(a) ->
+          if Enum.any?(acc, fn %App{name: app} -> a == app end) do
+            acc
+          else
+            get_apps(App.new(a), acc)
+          end
+      end)
     # Correct any ERTS libs which should be pulled from the correct
     # ERTS directory, not from the current environment.
-    apps = case release.profile.include_erts do
-             true  -> base_apps
-             false -> base_apps
-             p when is_binary(p) ->
-               lib_dir = Path.expand(Path.join(p, "lib"))
-               Enum.reduce(base_apps, [], fn
-                 _, {:error, {:apps, _}} = err ->
-                   err
-                 _, {:error, reason} ->
-                   {:error, {:apps, reason}}
-                 %App{name: a} = app, acc ->
-                    case is_erts_lib?(app.path) do
-                      false ->
-                        [app|acc]
-                      true ->
-                        case Path.wildcard(Path.join(lib_dir, "#{a}-*")) do
-                          [corrected_app_path|_] ->
-                            [_, corrected_app_vsn] = String.split(Path.basename(corrected_app_path), "-", trim: true)
-                            [%{app | :vsn => corrected_app_vsn,
-                                     :path => corrected_app_path} | acc]
-                          _ ->
-                            {:error, {:apps, {:missing_required_lib, a, lib_dir}}}
-                        end
-                    end
-               end)
-           end
+    apps =
+      case release.profile.include_erts do
+        true  -> base_apps
+        false -> base_apps
+        p when is_binary(p) ->
+          lib_dir = Path.expand(Path.join(p, "lib"))
+          Enum.reduce(base_apps, [], fn
+            _, {:error, {:apps, _}} = err ->
+              err
+            _, {:error, reason} ->
+              {:error, {:apps, reason}}
+            %App{name: a} = app, acc ->
+              if is_erts_lib?(app.path) do
+                case Path.wildcard(Path.join(lib_dir, "#{a}-*")) do
+                  [corrected_app_path|_] ->
+                    [_, corrected_app_vsn] = String.split(Path.basename(corrected_app_path), "-", trim: true)
+                    [%{app | :vsn => corrected_app_vsn,
+                              :path => corrected_app_path} | acc]
+                  _ ->
+                    {:error, {:apps, {:missing_required_lib, a, lib_dir}}}
+                end
+              else
+                [app|acc]
+              end
+          end)
+      end
     case apps do
       {:error, _} = err ->
         err

  def insecure_mkdir_temp() do
    :rand.seed(:exs64)
    unique_num = :rand.uniform(1_000_000_000)
    tmpdir_path = case :erlang.system_info(:system_architecture) do
                    'win32' ->
                      Path.join(["./tmp", ".tmp_dir#{unique_num}"])
                    _ ->
                      Path.join(["/tmp", ".tmp_dir#{unique_num}"])
                  end
    case File.mkdir_p(tmpdir_path) do
      :ok ->
        {:ok, tmpdir_path}

                    v1_commits_since > v2_commits_since
                end
              :lt -> false
            end
          {{_, v1}, {_, v2}} ->
            v1 >  v2
        end
