   (configuration-layer/init-layers)
   (configuration-layer/load-layers)
   (when dotspacemacs-delete-orphan-packages
-    (configuration-layer/delete-orphan-packages)))
+    (configuration-layer/delete-orphan-packages configuration-layer-packages)))
 
 (defun configuration-layer/create-layer ()
   "Ask the user for a configuration layer name and the layer

    (unless (string-empty-p version-string)
      (version-to-list version-string))))

(defun configuration-layer//package-delete (pkg)
  "Delete the passed PKG."
  (cond
   ((version< emacs-version "24.3.50")
    (let ((v (configuration-layer//get-package-version-string pkg)))
      (when v (package-delete (symbol-name pkg) v))))
   (t (let ((p (cadr (assq pkg package-alist))))
        (when p (package-delete p))))))

(defun configuration-layer//filter-used-themes (orphans)

                     result)))))
    result))

(defun configuration-layer//get-implicit-packages (packages)
  "Returns packages in `packages-alist' which are not found in PACKAGES."
  (let (imp-pkgs)
    (dolist (pkg package-alist)
      (let ((pkg-sym (car pkg)))
        (unless (object-assoc pkg-sym :name packages)
          (add-to-list 'imp-pkgs pkg-sym))))
    imp-pkgs))

(defun configuration-layer//get-orphan-packages (implicit-pkgs dependencies)
  "Return orphan packages."
  (let (result)
    (dolist (imp-pkg implicit-pkgs)
      (when (configuration-layer//is-package-orphan imp-pkg dependencies)
        (add-to-list 'result imp-pkg)))
    result))

(defun configuration-layer//is-package-orphan (pkg-name dependencies)
  "Returns not nil if PKG-NAME is the name of an orphan package."
  (unless (object-assoc pkg-name :name configuration-layer-packages)
    (if (ht-contains? dependencies pkg-name)
        (let ((parents (ht-get dependencies pkg-name)))
          (reduce (lambda (x y) (and x y))
                  (mapcar (lambda (p) (configuration-layer//is-package-orphan
                                       p dependencies))
                          parents)
                  :initial-value t))
      (not (object-assoc pkg-name :name configuration-layer-packages)))))

(defun configuration-layer//get-package-directory (pkg)
  "Return the directory path for PKG."
