 
    ;; Turning the mode ON.
    (live-py-mode
-    ;; create a unique name for the trace output buffer
-    (set (make-local-variable 'live-py-output-buffer)
-         (concat "*live-py-output_"
-                 (file-name-nondirectory (buffer-file-name))
-                 "_"
-                 (make-temp-name "")
-                 "*"))
-    (set (make-local-variable 'live-py-timer) nil)
-    (set (make-local-variable 'live-py-driver) nil)
-    (set (make-local-variable 'live-py-module) (file-name-base buffer-file-name))
-    (set (make-local-variable 'live-py-dir) (file-name-directory buffer-file-name))
-    (set (make-local-variable 'live-py-path) nil)
-    (set (make-local-variable 'live-py-version) "python")
-    (set (make-local-variable 'live-py-window-start-pos) -1)
-    (set (make-local-variable 'live-py-point-line-nr) -1)
+    (setq live-py-dir (file-name-directory buffer-file-name)
+          live-py-version "python")
+    ;; Create a unique name for the trace output buffer.
+    (setq-local live-py-output-buffer
+                (concat "*live-py-output_"
+                        (file-name-nondirectory (buffer-file-name))
+                        "_"
+                        (make-temp-name "")
+                        "*"))
+    (setq-local live-py-module (file-name-base buffer-file-name))
+    (setq-local live-py-window-start-pos -1)
+    (setq-local live-py-point-line-nr -1)
     (add-hook 'kill-buffer-hook 'live-py-mode-off nil t)
     (add-hook 'after-change-functions 'live-py-after-change-function nil t)
     (live-py-show-output-window)

        (point-line-nr (line-number-at-pos)))
    (unless (and (= live-py-window-start-pos window-start-pos)
                 (= live-py-point-line-nr point-line-nr))
      (set (make-local-variable 'live-py-window-start-pos) window-start-pos)
      (set (make-local-variable 'live-py-point-line-nr) point-line-nr)
      (if (buffer-live-p (and live-py-output-buffer
                              (get-buffer live-py-output-buffer)))
          (progn

;; If that doesn't work, put the following in your Emacs configuration file:
;;
;;   (require 'live-py-mode)

;;; Code:

;; User variables. The decision if local or not has to be left to the user.
(defvar live-py-driver nil)
(defvar live-py-dir nil)
(defvar live-py-path nil)
(defvar live-py-version nil)

;; Internal variables.
(defvar live-py-output-window nil)
(defvar-local live-py-timer nil)
(defvar-local live-py-output-buffer nil "The name of the output buffer.")
(defvar-local live-py-module nil)
(defvar-local live-py-parent nil)
(defvar-local live-py-window-start-pos nil)
(defvar-local live-py-point-line-nr nil)
(defvar-local live-py-lighter nil)

(defun live-py-after-change-function (start stop len)
  "After a delay run the buffer through the code tracer and show trace.
START, STOP and LEN are required by `after-change-functions' but unused."
  (ignore start stop len)
  (when live-py-timer (cancel-timer live-py-timer))
  (setq-local live-py-timer (run-at-time 0.5 nil 'live-py-trace)))

(defun live-py-trace ()
  "Trace the Python code using code_tracer.py."
