diff --git a/Ganeti/HTools/CLI.hs b/Ganeti/HTools/CLI.hs
index bc2dad0a29f31278a44179e334ecf5898f698124..12f1fef5189147b6058c53f72353923071c15ce8 100644
--- a/Ganeti/HTools/CLI.hs
+++ b/Ganeti/HTools/CLI.hs
@@ -33,6 +33,7 @@ module Ganeti.HTools.CLI
     , parseOpts
     , shTemplate
     , defaultLuxiSocket
+    , maybePrintNodes
     -- * The options
     , oDataFile
     , oDiskMoves
@@ -417,3 +418,14 @@ shTemplate =
            \    exit 0\n\
            \  fi\n\
            \}\n\n"
+
+-- | Optionally print the node list.
+maybePrintNodes :: Maybe [String]       -- ^ The field list
+                -> String               -- ^ Informational message
+                -> ([String] -> String) -- ^ Function to generate the listing
+                -> IO ()
+maybePrintNodes Nothing _ _ = return ()
+maybePrintNodes (Just fields) msg fn = do
+  hPutStrLn stderr ""
+  hPutStrLn stderr (msg ++ " status:")
+  hPutStrLn stderr $ fn fields
diff --git a/hbal.hs b/hbal.hs
index 4f2039796e4007d55f0cc3c7726f209e7a8a4769..c70d6ca4eb91c5210e8ca5117a8ed5646d00152f 100644
--- a/hbal.hs
+++ b/hbal.hs
@@ -333,10 +333,7 @@ main = do
          putStrLn "Initial instance map:"
          putStrLn $ Cluster.printInsts nl il
 
-  when (isJust shownodes) $
-       do
-         putStrLn "Initial cluster status:"
-         putStrLn $ Cluster.printNodes nl (fromJust shownodes)
+  maybePrintNodes shownodes "Initial cluster" (Cluster.printNodes nl)
 
   let ini_cv = Cluster.compCV nl
       ini_tbl = Cluster.Table nl il ini_cv []
@@ -405,19 +402,15 @@ main = do
          putStrLn "Final instance map:"
          putStr $ Cluster.printInsts fin_nl fin_il
 
-  when (isJust shownodes) $
-       do
+  maybePrintNodes shownodes "Final cluster" (Cluster.printNodes fin_nl)
+
+  when (verbose > 3) $ do
          let ini_cs = Cluster.totalResources nl
              fin_cs = Cluster.totalResources fin_nl
-         putStrLn ""
-         putStrLn "Final cluster status:"
-         putStrLn $ Cluster.printNodes fin_nl (fromJust shownodes)
-         when (verbose > 3) $
-              do
-                printf "Original: mem=%d disk=%d\n"
-                       (Cluster.csFmem ini_cs) (Cluster.csFdsk ini_cs) :: IO ()
-                printf "Final:    mem=%d disk=%d\n"
-                       (Cluster.csFmem fin_cs) (Cluster.csFdsk fin_cs)
+         printf "Original: mem=%d disk=%d\n"
+                    (Cluster.csFmem ini_cs) (Cluster.csFdsk ini_cs) :: IO ()
+         printf "Final:    mem=%d disk=%d\n"
+                    (Cluster.csFmem fin_cs) (Cluster.csFdsk fin_cs)
   when oneline $
          putStrLn $ formatOneline ini_cv (length ord_plc) fin_cv
 
diff --git a/hspace.hs b/hspace.hs
index 9343240a5f5fedd719210c8633e1263fcdfafce7..349a85a3475b0ac348c9983696e6aa2315e26970 100644
--- a/hspace.hs
+++ b/hspace.hs
@@ -295,10 +295,8 @@ main = do
                  formatTable (map (printInstance trl_nl) (reverse trl_ixes))
                                  [False, False, False, True, True, True]
 
-       when (isJust shownodes) $ do
-         hPutStrLn stderr ""
-         hPutStrLn stderr "Tiered allocation status:"
-         hPutStrLn stderr $ Cluster.printNodes trl_nl (fromJust shownodes)
+       maybePrintNodes shownodes "Tiered allocation"
+                           (Cluster.printNodes trl_nl)
 
        maybeSaveData (optSaveCluster opts) "tiered" "after tiered allocation"
                      (ClusterData gl trl_nl trl_il ctags)
@@ -323,11 +321,7 @@ main = do
          hPutStr stderr . unlines . map ((:) ' ' .  intercalate " ") $
                  formatTable (map (printInstance fin_nl) fin_ixes)
                                  [False, False, False, True, True, True]
-  when (isJust shownodes) $
-       do
-         hPutStrLn stderr ""
-         hPutStrLn stderr "Final cluster status:"
-         hPutStrLn stderr $ Cluster.printNodes fin_nl (fromJust shownodes)
+  maybePrintNodes shownodes "Standard allocation" (Cluster.printNodes fin_nl)
 
   maybeSaveData (optSaveCluster opts) "alloc" "after standard allocation"
        (ClusterData gl fin_nl fin_il ctags)