diff --git a/matlab-syntax.el b/matlab-syntax.el
index 18203a5..f367004 100644
--- a/matlab-syntax.el
+++ b/matlab-syntax.el
@@ -451,7 +451,10 @@ Returns non-nil if the cursor is in a comment."
 	  (goto-char (nth 8 pps))
 	  
 	  t)
-      (when all-comments (forward-comment -100000)))))
+      (when all-comments
+	(prog1
+	    (forward-comment -100000)
+	  (skip-chars-forward " \t\n\r"))))))
 
 (defun matlab-end-of-string-or-comment (&optional all-comments)
   "If the cursor is in a string or comment, move to the end.
@@ -467,7 +470,8 @@ Returns non-nil if the cursor moved."
 	  (goto-char (nth 8 pps))
 	  (if (nth 3 pps)
 	      (goto-char (scan-sexps (point) 1))
-	    (forward-comment (if all-comments 100000 1)))
+	    (forward-comment (if all-comments 100000 1))
+	    (skip-chars-backward " \t\n\r"))
 	  ;; If the buffer is malformed, we might end up before starting pt.
 	  ;; so error.
 	  (when (< (point) start)
@@ -477,6 +481,7 @@ Returns non-nil if the cursor moved."
       ;; else not in comment, but still skip 'all-comments' if requested.
       (when (and all-comments (looking-at "\\s-*\\s<"))
 	(forward-comment 100000)
+	(skip-chars-backward " \t\n\r")
 	t)
       )))
 
diff --git a/matlab.el b/matlab.el
index eaa1416..e4de2d0 100644
--- a/matlab.el
+++ b/matlab.el
@@ -1303,7 +1303,6 @@ All Key Bindings:
 \\{matlab-mode-map}"
   :after-hook (matlab-mode-init-mlint-if-needed)
 
-  (kill-all-local-variables)
   (use-local-map matlab-mode-map)
   (setq major-mode 'matlab-mode)
   (setq mode-name "MATLAB")
@@ -1689,7 +1688,7 @@ The name is any text after the %% and any whitespace."
 (defun matlab-beginning-of-command ()
   "Go to the beginning of an M command.
 Travels across continuations."
-  (interactive "P")
+  (interactive)
   (matlab-scan-beginning-of-command))
 
 (defun matlab-end-of-command ()
@@ -1773,7 +1772,7 @@ If there isn't one, then return nil, point otherwise."
   "Indent the region between START And END for MATLAB mode.
 Unlike `indent-region-line-by-line', this function captures
 parsing state and re-uses that state along the way."
-  (interactive)
+  (interactive "r")
   (save-excursion
     (setq end (copy-marker end))
     (goto-char start)
@@ -2381,19 +2380,28 @@ Argument BEG and END indicate the region to uncomment."
 (defun matlab-set-comm-fill-prefix ()
   "Set the `fill-prefix' for the current (comment) line."
   (interactive)
-  (if (matlab-line-comment-p (matlab-compute-line-context 1))
-      (setq fill-prefix
-	    (save-excursion
-	      (beginning-of-line)
-	      (let ((e (matlab-point-at-eol))
-		    (pf nil))
-		(while (and (re-search-forward "%+[ \t]*\\($$$ \\|\\* \\)?" e t)
-			    (matlab-cursor-in-string)))
-		(setq pf (match-string 0))
-		(when (string-match "%\\s-*\\* " pf)
-		  (setq pf (concat "%" (make-string (1- (length pf)) ?  ))))
-		(concat (make-string (- (current-column) (length pf)) ? )
-			pf))))))
+  (let ((ctxt (matlab-compute-line-context 1)))
+    (if (matlab-line-comment-p ctxt)
+	(setq fill-prefix
+	      (save-excursion
+		(beginning-of-line)
+		(let ((e (matlab-point-at-eol))
+		      (pf nil))
+		  (while (and (re-search-forward "%+[ \t]*\\($$$ \\|\\* \\)?" e t)
+			      (matlab-cursor-in-string)))
+		  (setq pf (match-string 0))
+		  (when (string-match "%\\s-*\\* " pf)
+		    (setq pf (concat "%" (make-string (1- (length pf)) ?  ))))
+		  (concat (make-string (- (current-column) (length pf)) ? )
+			  pf))))
+      ;; Not a comment line, but maybe a comment at end of a line?  If
+      ;; so make next comment line up with the end of line comment
+      ;; column the way aoto fill does.
+      (let ((cstart (matlab-line-end-comment-column ctxt)))
+	(if cstart
+	    (setq fill-prefix
+		  (concat (make-string cstart ? ) "% "))
+	    )) )))
 
 (defun matlab-set-comm-fill-prefix-post-code ()
   "Set the `fill-prefix' for the current post-code comment line."
@@ -2545,7 +2553,7 @@ filling which will automatically insert `...' and the end of a line."
 	 ((or (matlab-line-comment-p lvl1)
 	      (and (save-excursion (move-to-column fill-column)
 				   (matlab-cursor-in-comment))
-		   (matlab-line-comment-p lvl1)))
+		   (matlab-line-end-comment-column lvl1)))
 	  ;; If the whole line is a comment, do this.
 	  (matlab-set-comm-fill-prefix) (do-auto-fill)
 	  (matlab-reset-fill-prefix))
@@ -2655,33 +2663,9 @@ With optional argument, JUSTIFY the comment as well."
   (interactive)
   (if (not (matlab-comment-on-line))
       (error "No comment to fill"))
-  (beginning-of-line)
-  ;; First, find the beginning of this comment...
-  (while (and (looking-at matlab-cline-start-skip)
-	      (not (bobp)))
-    (forward-line -1)
-    (beginning-of-line))
-  (if (not (looking-at matlab-cline-start-skip))
-      (forward-line 1))
-  ;; Now scan to the end of this comment so we have our outer bounds,
-  ;; and narrow to that region.
-  (save-restriction
-    (narrow-to-region (point)
-		      (save-excursion
-			(while (and (looking-at matlab-cline-start-skip)
-				    (not (save-excursion (end-of-line) (eobp))))
-			  (forward-line 1)
-			  (beginning-of-line))
-			(if (not (looking-at matlab-cline-start-skip))
-			    (forward-line -1))
-			(end-of-line)
-			(point)))
-    ;; Find the fill prefix...
-    (matlab-comment-on-line)
-    (looking-at "%[ \t]*")
-    (let ((fill-prefix (concat (make-string (current-column) ? )
-			       (match-string 0))))
-      (fill-region (point-min) (point-max) justify))))
+  ;; Set the fill prefix
+  (matlab-set-comm-fill-prefix)
+  (fill-paragraph justify))
 
 (defun matlab-justify-line ()
   "Delete space on end of line and justify."
@@ -2696,6 +2680,8 @@ With optional argument, JUSTIFY the comment as well."
 Paragraphs are always assumed to be in a comment.
 ARG is passed to `fill-paragraph' and will justify the text."
   (interactive "P")
+
+  ;;; Comment Filling
   (cond ((or (matlab-line-comment-p (matlab-compute-line-context 1))
 	     (and (matlab-cursor-in-comment)
 		  (not (matlab-line-ellipsis-p (matlab-compute-line-context 1)))))
@@ -2705,19 +2691,24 @@ ARG is passed to `fill-paragraph' and will justify the text."
 	 (let ((paragraph-separate "%%\\|%[a-zA-Z]\\|%[ \t]*$\\|[ \t]*$")
 	       (paragraph-start "%[a-zA-Z]\\|%[ \t]*$\\|[ \t]*$\\|%\\s-*\\*")
 	       (paragraph-ignore-fill-prefix nil)
-	       (start (save-excursion (matlab-scan-beginning-of-command)
+	       (start (save-excursion (matlab-beginning-of-string-or-comment t)
 				      (if (looking-at "%%")
 					  (progn (end-of-line)
 						 (forward-char 1)))
 				      (point-at-bol)))
-	       (end (save-excursion (matlab-scan-end-of-command)))
+	       (end (save-excursion (matlab-end-of-string-or-comment t)
+				    (point)))
 	       (fill-prefix nil))
-	   (matlab-set-comm-fill-prefix)
+	   (save-excursion
+	     (goto-char start)
+	     (matlab-set-comm-fill-prefix))
 	   (save-restriction
 	     ;; Ben North fixed to handle comment at the end of
 	     ;; a buffer.
 	     (narrow-to-region start (min (point-max) (+ end 1)))
-	     (fill-paragraph arg))))
+	     (fill-comment-paragraph arg))))
+
+	;;; Command Filling
 	((let ((lvl  (matlab-compute-line-context 1)))
 	   (not (or (matlab-line-comment-p lvl) (matlab-line-empty-p lvl))))
 	 ;; Ok, lets get the outer bounds of this command, then
@@ -2766,6 +2757,7 @@ ARG is passed to `fill-paragraph' and will justify the text."
 	   (if arg (save-excursion
 		     (forward-line -1)
 		     (matlab-justify-line)))))
+	
 	(t
 	 (message "Paragraph Fill not supported in this context."))))
 
