       (delete-process (merlin-get-process))
       (cancel-timer merlin-idle-timer)
       (delete-overlay merlin-overlay)
+      (if merlin-enclosing-overlay merlin-enclosing-overlay)
       (merlin-delete-error-overlays)
       (kill-buffer (merlin-make-buffer-name))
 )))

    (define-key map (kbd "C-c C-x") 'merlin-next-error)
    (define-key map (kbd "C-c C-r") 'merlin-rewind)
    (define-key map (kbd "C-c C-u") 'merlin-refresh)
    (define-key map (kbd "RET") 'merlin-enter)
    map
    ))

  (if (> arg 1)
      (merlin-show-type-of-region)
    (merlin-show-type (bounds-of-thing-at-point 'ocamlatom))))

;; ENCLOSING TYPES
(defun merlin-type-enclosing ()
  "If there is a selected type enclosing, kill it. Otherwise start a new session at point"
  (interactive)
  (if (not merlin-enclosing-types)
      (let ((list
             (mapcar
              '(lambda (obj)
                 (cons
                  (cdr (assoc 'type obj))
                  (merlin-make-bounds obj)))
              (elt
               (merlin-is-return
                (merlin-send-command "type" (list "enclosing" (merlin-unmake-point (point)))))
               1))))
        (setq merlin-enclosing-types list)
        (setq merlin-enclosing-offset -1))
    (progn
      (setq merlin-enclosing-types nil)
      (setq merlin-enclosing-offset nil)
      (delete-overlay merlin-enclosing-overlay)
      (setq merlin-enclosing-overlay nil))))

(defun merlin-type-enclosing-go ()
  "Highlight the given corresponding enclosing data (of the form (type . bounds)"
  (let ((data (elt merlin-enclosing-types merlin-enclosing-offset)))
    (merlin-create-overlay 'merlin-enclosing-overlay (cdr data) 'next-error nil)
    (message "%s" (car data))))

(defun merlin-type-enclosing-go-up ()
  "Goes up in the enclosing type zipper."
  (interactive)
  (if merlin-enclosing-types
      (if (> merlin-enclosing-offset (length merlin-enclosing-types))
          (message "cannot go up")
        (progn
          (setq merlin-enclosing-offset (+ 1 merlin-enclosing-offset))
          (merlin-type-enclosing-go)
          ))))

(defun merlin-type-enclosing-go-down ()
  "Goes down in the enclosing type zipper."
  (interactive)
  (if merlin-enclosing-types
      (if (<= merlin-enclosing-offset 0)
          (message "cannot go down")
        (progn
          (setq merlin-enclosing-offset (- merlin-enclosing-offset 1))
          (merlin-type-enclosing-go)
          ))))

;; .merlin parsing
(defun merlin-add-path (kind dir)
