       (let ((col-start-index 0)
             (col-end-index (1- n-rows))
             (total-width 0)
-            (split-factor
-             ; STEVE comment
-             (loop for i from 2 upto (ash n-rows -1)
-                   when (zerop (mod n-rows i))
-                   return (/ n-rows i))))
+            (split-factor (aref lusty--greatest-factors n-rows)))
 
         ;; Calculate required total-width for this number of rows.
-        (do ((separator-len 0 (length lusty-column-separator)))
-            ((>= col-end-index n-items))
+        (while (>= col-end-index n-items)
           (let ((column-width
                  (lusty--compute-column-width
                   col-start-index col-end-index split-factor

(defvar lusty--ignored-extensions-regex nil)
(defvar lusty--highlighted-index 0)
(defvar lusty--previous-printed-matches '())

(when lusty--wrapping-ido-p
  (require 'ido))

            ;; Remainder; last iteration will not be a full column.
            (setq col-end-index (1- n-items)
                  split-factor nil)))

        ;; The final column doesn't need a separator.
        (decf total-width separator-length)

        (when (<= total-width available-width)
          (return-from lusty--compute-optimal-layout-inner
