     ; Restore paths
     (setenv "PATH" (assoc-default 'path-backup hsenv-active-environment))
     (setq exec-path (assoc-default 'exec-path-backup hsenv-active-environment))
+    ; Unset variables
+    (setenv "PACKAGE_DB_FOR_GHC")
+    (setenv "PACKAGE_DB_FOR_GHC_PKG")
+    (setenv "PACKAGE_DB_FOR_GHC_MOD")
+    (setenv "PACKAGE_DB_FOR_CABAL")
+    (setenv "HSENV")
+    (setenv "HSENV_NAME")
+    (setenv "HASKELL_PACKAGE_SANDBOX")
     ; Destroy the hsenv active environment
     (let ((old-dir (cdr (assoc 'dir hsenv-active-environment))))
       (setq hsenv-active-environment nil)


(defconst hsenv-path-prepend-file "path_var_prependix")
(defconst hsenv-ghc-package-path-file "ghc_package_path_var")

(defun hsenv-valid-dirp (hsenv-dir)
  (let ((valid (and (file-accessible-directory-p hsenv-dir)

             (env (assoc env-name environments)))
        (let* ((hsenv-dir-name (hsenv-env-dir env))
               (hsenv-dir (file-name-as-directory hsenv-dir-name)))
          (hsenv-activate-environment hsenv-dir dir env-name))))))

(defun hsenv-list-environments (dir)
  "Returns an assoc list of all environments avaliable in DIR.

The assoc list contains pairs of the form (NAME . DIRECTORY)."
  (let ((hsenv-dirs (directory-files dir t "^\\.hsenv\\(_.*\\)?$")))
    (mapcar #'hsenv-make-env hsenv-dirs)))

(defun hsenv-activate (&optional select-dir)
