          (target-file (file-name-nondirectory (buffer-file-name)))
          (type-file (concat (file-name-sans-extension (buffer-file-name))
                             ".annot"))
-         (type-buf (caml-types-find-file type-file))
          (target-line) (target-bol)
          target-pos
-         Left Right limits cnum node mes ty-start ty-end
+         Left Right limits cnum node mes type
          (tree caml-types-annotation-tree)
          )
-    (caml-types-preprocess type-file type-buf)
+    (caml-types-preprocess type-file)
+    (unless caml-types-buffer 
+      (setq caml-types-buffer (get-buffer-create caml-types-buffer-name)))
     ; (message "Drag the mouse to explore types")
     (unwind-protect
         (track-mouse

                    (1+ (count-lines (point-min) target-bol)))
              (setq target-pos (vector target-file target-line target-bol cnum))
              (save-excursion
                (set-buffer type-buf)
                (widen)
                (setq node (caml-types-find-location target-pos () tree))
                (cond
                 (node
                  (setq Left (caml-types-get-pos target-buf (elt node 0)))

       ((null node)
        (delete-overlay caml-types-expr-ovl)
        (message "Point is not within a typechecked expression or pattern.")
        ; (with-current-buffer type-buf (narrow-to-region 1 1))
        )
       (t
        (let ((left (caml-types-get-pos target-buf (elt node 0)))
              (right (caml-types-get-pos target-buf (elt node 1)))
              (type (elt node 2)))
          (move-overlay caml-types-expr-ovl left right target-buf)
          (with-current-buffer caml-types-buffer
            (erase-buffer)
            (insert type)
            (message (format "type: %s" type)))
          ))))
    (if (and (= arg 4)
             (not (window-live-p (get-buffer-window caml-types-buffer))))
        (display-buffer caml-types-buffer))
    (unwind-protect
        (sit-for 60)
      (delete-overlay caml-types-expr-ovl))))

(defun caml-types-preprocess (type-file)
  (let* ((type-date (nth 5 (file-attributes type-file)))
         (target-file (file-name-nondirectory (buffer-file-name)))
         (target-date (nth 5 (file-attributes target-file))))
