   ; Really start process
   (let ((binary      (merlin-command))
         (flags       (merlin-lookup 'flags merlin-buffer-configuration))
-        (process-environment (merlin-lookup 'env merlin-buffer-configuration))
+        (process-environment (copy-list process-environment))
         ; FIXME use logfile
         (logfile     (or (merlin-lookup 'logfile merlin-buffer-configuration)
                          merlin-logfile))

    (merlin-transform-display-errors errors)
    (when view-errors-p
      (let ((prefix (current-message)))
	(setq prefix (if prefix (concat prefix " ") ""))
	(if merlin-erroneous-buffer
	    (message "%s(%d pending errors, use %s to jump)"
		     prefix
		     (length errors)
		     (substitute-command-keys "\\[merlin-error-next]"))
	  (message "%sNo errors" prefix))))))

(defun merlin-error-after-save ()
  "Determine whether the buffer should be checked for errors depending on the value of merlin-error-after-save setting."

    ;; When disabling merlin
    (progn
      (when merlin-highlight-overlay
        (delete-overlay merlin-highlight-overlay))
      (remove-overlays nil nil 'merlin-kind 'highlight)
      (remove-overlays nil nil 'merlin-kind 'error))))

