--- a/share/dynamics/plotdf.lisp
+++ b/share/dynamics/plotdf.lisp
@@ -28,48 +28,52 @@
 
 ;; parses a plotdf option into a command-line option for tcl scripts
 (defun plotdf-option-to-tcl (value s1 s2)
-  (let (vv)
+  (let (v vv)
     (unless (and  ($listp value)
                   (symbolp (setq name (second value))))
       (merror
-       (intl:gettext "plotdf-option-to-tcl: ~M is not a plotdf option. Should be [symbol,...data]")
-       value))
-    (setq value
-      (case name
-        (($xradius $yradius $xcenter $ycenter $tinitial $tstep)
-         (check-list-items name (rest (rest value)) 'number 1))
-        (($width $height $nsteps $versus_t)
-         (check-list-items name (rest (rest value)) 'fixnum 1))
-        ($trajectory_at
-         (check-list-items name (rest (rest value)) 'number 2))
-        ($bbox (check-list-items name (rest (rest value)) 'number 4))
-        (($xfun $parameters $sliders $vectors $fieldlines $curves 
-		$windowtitle $xaxislabel $yaxislabel $psfile) value)
-	($axes
-	 (if (not (third value))
-	     (setq value '((mlist) $axes 0))  
-	   (case (third value)
-		 ($x (setq value '((mlist) $axes "x")))
-		 ($y (setq value '((mlist) $axes "y")))
-		 (t (setq value '((mlist) $axes "xy"))))))
-	($box
-	 (if (not (third value))
-	     (setq value '((mlist) $nobox 1))
+       (intl:gettext
+        "plotdf-option-to-tcl: Expecting a symbol for the option name, found: \"~M\"") value))
+    (case name
+      (($xradius $yradius $xcenter $ycenter $tinitial $tstep)
+       (setq v (check-option (cdr value) #'realp "a real number" 1))
+       (setq value (list '(mlist) name v)))
+      (($width $height $nsteps $versus_t)
+       (setq v (check-option (cdr value) #'naturalp "a natural number" 1))
+       (setq value (list '(mlist) name v)))
+      ($trajectory_at
+       (setq v (check-option (cdr value) #'realp "a real number" 2))
+       (setq value (cons '(mlist) (cons name v))))
+      ($bbox
+       (setq v (check-option (cdr value) #'realp "a real number" 4))
+       (setq value (cons '(mlist) (cons name v))))
+      (($xfun $parameters $sliders $vectors $fieldlines $curves 
+              $windowtitle $xaxislabel $yaxislabel $psfile)
+       (setq v (check-option (cdr value) #'stringp "a string" 1))
+       (setq value (list '(mlist) name v)))
+      ($axes
+       (if (not (third value))
+           (setq value '((mlist) $axes 0))  
+           (case (third value)
+             ($x (setq value '((mlist) $axes "x")))
+             ($y (setq value '((mlist) $axes "y")))
+             (t (setq value '((mlist) $axes "xy"))))))
+      ($box
+       (if (not (third value))
+           (setq value '((mlist) $nobox 1))
 	   (setq value '((mlist) $nobox 0))))
-        ($direction
-         (or
-          (member (ensure-string (third value)) '("forward" "backward" "both") :test #'equal)
-          (merror
-           (intl:gettext "plotdf-option-to-tcl: direction should be forward, backward or both."))) 
-         value)
-        (t (cond
-            ((eql name s1)
-	     (setq value (check-range value))
-             (check-list-items '$x (rest (rest value)) 'number 2))
-            ((eql name s2)
-	     (setq value (check-range value))
-             (check-list-items '$y (rest (rest value)) 'number 2))
-            (t (merror (intl:gettext "plotdf-option-to-tcl: unknown option ~M") name))))))
+      ($direction
+       (or
+        (member (ensure-string (third value)) '("forward" "backward" "both") :test #'equal)
+        (merror
+         (intl:gettext
+          "plotdf-option-to-tcl: direction should be forward, backward or both."))))
+      (t (cond
+           ((eql name s1)
+            (setq value (cons '(mlist) (cons '$x (cddr (check-range value))))))
+           ((eql name s2)
+            (setq value (cons '(mlist) (cons '$y (cddr (check-range value))))))
+           (t (merror (intl:gettext "plotdf-option-to-tcl: unknown option ~M") name)))))
     (setq vv (mapcar #'(lambda (a) (if (symbolp a) (ensure-string a) a)) (cdr value)))
     (with-output-to-string (st)
       (cond ((or (equal (first vv) "x") (equal (first vv) "y"))
@@ -90,22 +94,18 @@
 ;; system of 2 equations dx/dt = f(x,y), dy/dt = g(x,y) 
 ;;
 (defun $plotdf (ode &rest options)  
-  (let (cmd (opts " ") (s1 '$x) (s2 '$y))
+  (let (file cmd (opts " ") (s1 '$x) (s2 '$y) vars)
     (unless ($listp ode) (setf ode `((mlist) ,ode)))
 
-    ;; parse arguments and prepare string cmd with the equation(s)
-    (unless
-	(member (second (first options))
-		'($xradius $yradius $xcenter $ycenter $tinitial $tstep
-			   $width $height $nsteps $versus_t $xfun $parameters
-			   $sliders $vector $trajectory_at $orthogonal))
-      (if (and (listp (first options)) (= (length (first options)) 3)
-	       (symbolp (second (first options)))
-	       (symbolp (third (first options))))
-	  (progn
-	    (setf s1 (second (first options)))
-	    (setf s2 (third (first options)))))
-      (setf options (cdr options)))
+    ;; if the variables are not x and y, their names must be given right
+    ;; after the expression for the ode's
+    (when
+      (and (listp (car options)) (= (length (car options)) 3)
+            (or (symbolp (cadar options)) ($subvarp (cadar options)))
+            (or (symbolp (caddar options)) ($subvarp (caddar options))))
+      (setq s1 (cadar options))
+      (setq s2 (caddar options))
+      (setq options (cdr options)))
 
     ;; parse options and copy them to string opts
     (cond (options
@@ -119,8 +119,9 @@
       (setq opts (concatenate 'string opts " -yaxislabel " (ensure-string s2))))
 
     ;; check that the expressions given contain only the axis variables
+    (setq vars (cdr (mfuncall '$listofvars ode)))
     (unless (search "-parameters " opts)
-      (dolist (var (cdr (mfuncall '$listofvars ode)))
+      (dolist (var vars)
         (unless (or (eq var s1) (eq var s2))
           (merror 
            (intl:gettext "plotdf: expression(s) given can only depend on ~M and ~M~%Found extra variable ~M") s1 s2 var))))
@@ -141,35 +142,35 @@
                                     (expr_to_str (second ode)) "\"")))
           (t (merror 
               (intl:gettext "plotdf: first argument must be either an expression or a list with two expressions."))))
-    
+    (setq file (plot-temp-file "maxout.xmaxima"))
     (show-open-plot
-     (with-output-to-string (st)
-                  (cond ($show_openplot (format st "plotdf ~a ~a~%" cmd opts))
-                              (t (format st "{plotdf ~a ~a} " cmd opts)))))))
+     (with-output-to-string
+         (st)
+       (cond
+         ($show_openplot (format st "plotdf ~a ~a~%" cmd opts))
+         (t (format st "{plotdf ~a ~a} " cmd opts))))
+     file)
+    file))
 
 ;; plot equipotential curves for a scalar field f(x,y)
 (defun $ploteq (fun &rest options)
   
-  (let (cmd mfun (opts " ") (s1 '$x) (s2 '$y))
+  (let (file cmd mfun (opts " ") (s1 '$x) (s2 '$y))
     (setf mfun `((mtimes) -1 ,fun))
-    ;; parse arguments and prepare string cmd with the equation(s)
-    (unless
-	(member (second (first options))
-		'($xradius $yradius $xcenter $ycenter $tinitial $tstep
-			   $width $height $nsteps $versus_t $xfun $parameters
-			   $sliders $vector $trajectory $orthogonal))
-      (if (and (listp (first options)) (= (length (first options)) 3)
-	       (symbolp (second (first options)))
-	       (symbolp (third (first options))))
-	  (progn
-	    (setf s1 (second (first options)))
-	    (setf s2 (third (first options)))
-	    (defun subxy (expr)
-	      (if (listp expr)
-		  (mapcar #'subxy expr)
-		(cond ((eq expr s1) '$x) ((eq expr s2) '$y) (t expr))))
-	    (setf mfun (mapcar #'subxy mfun))
-	    (setf options (cdr options)))))
+    ;; if the variables are not x and y, their names must be given right
+    ;; after the expression for the ode's
+    (when
+      (and (listp (car options)) (= (length (car options)) 3)
+            (or (symbolp (cadar options)) ($subvarp (cadar options)))
+            (or (symbolp (caddar options)) ($subvarp (caddar options))))
+      (setq s1 (cadar options))
+      (setq s2 (caddar options))
+      (setq options (cdr options)))
+    (defun subxy (expr)
+      (if (listp expr)
+          (mapcar #'subxy expr)
+          (cond ((eq expr s1) '$x) ((eq expr s2) '$y) (t expr))))
+    (setf mfun (mapcar #'subxy mfun))
 ;; the next two lines should take into account parameters given in the options
 ;;    (if (delete '$y (delete '$x (rest (mfuncall '$listofvars ode))))
 ;;        (merror "The equation(s) can depend only on 2 variable which must be specified!"))
@@ -198,7 +199,11 @@
     (unless (search "-yaxislabel " opts)
       (setq opts (concatenate 'string opts " -yaxislabel " (ensure-string s2))))
 							      
+    (setq file (plot-temp-file "maxout.xmaxima"))
     (show-open-plot
-     (with-output-to-string (st)
-                  (cond ($show_openplot (format st "plotdf ~a ~a~%" cmd opts))
-                              (t (format st "{plotdf ~a ~a}" cmd opts)))))))
+     (with-output-to-string
+         (st)
+       (cond ($show_openplot (format st "plotdf ~a ~a~%" cmd opts))
+             (t (format st "{plotdf ~a ~a}" cmd opts))))
+     file)
+    file))