diff --git a/Hledger/Cli/Balance.hs b/Hledger/Cli/Balance.hs
--- a/Hledger/Cli/Balance.hs
+++ b/Hledger/Cli/Balance.hs
@@ -147,7 +147,11 @@
 -- | Render one balance report line item as plain text.
 accountsReportItemAsText :: ReportOpts -> [FormatString] -> AccountsReportItem -> [String]
 accountsReportItemAsText opts format (_, accountName, depth, Mixed amounts) =
-    case amounts of
+    -- 'amounts' could contain several quantities of the same commodity with different price.
+    -- In order to combine them into single value (which is expected) we take the first price and
+    -- use it for the whole mixed amount. This could be suboptimal. XXX
+    let Mixed normAmounts = normaliseMixedAmountPreservingFirstPrice (Mixed amounts) in
+    case normAmounts of
       [] -> []
       [a] -> [formatAccountsReportItem opts (Just accountName) depth a format]
       (as) -> multiline as
diff --git a/Hledger/Cli/Convert.hs b/Hledger/Cli/Convert.hs
--- a/Hledger/Cli/Convert.hs
+++ b/Hledger/Cli/Convert.hs
@@ -25,8 +25,8 @@
 import Hledger
 import Hledger.Cli.Format
 import qualified Hledger.Cli.Format as Format
-import Hledger.Cli.Version
 import Hledger.Cli.Options
+import Hledger.Cli.Version
 
 {- |
 A set of data definitions and account-matching patterns sufficient to
@@ -144,7 +144,7 @@
 
 initialRulesFileContent :: String
 initialRulesFileContent =
-    "# csv conversion rules file generated by "++(progversionstr progname)++"\n" ++
+    "# csv conversion rules file generated by " ++ prognameandversion ++ "\n" ++
     "# Add rules to this file for more accurate conversion, see\n"++
     "# http://hledger.org/MANUAL.html#convert\n" ++
     "\n" ++
diff --git a/Hledger/Cli/Main.hs b/Hledger/Cli/Main.hs
--- a/Hledger/Cli/Main.hs
+++ b/Hledger/Cli/Main.hs
@@ -65,12 +65,12 @@
   args <- getArgs
   addons <- getHledgerAddonCommands
   opts <- getHledgerCliOpts addons
-  when (debug_ opts) $ printf "%s\n" progversion >> printf "opts: %s\n" (show opts)
+  when (debug_ opts) $ printf "%s\n" prognameandversion >> printf "opts: %s\n" (show opts)
   run' opts addons args
     where
       run' opts@CliOpts{command_=cmd} addons args
        -- delicate, add tests before changing (eg --version, ADDONCMD --version, INTERNALCMD --version)
-       | (null matchedaddon) && "version" `in_` (rawopts_ opts)         = putStrLn progversion
+       | (null matchedaddon) && "version" `in_` (rawopts_ opts)         = putStrLn prognameandversion
        | (null matchedaddon) && "binary-filename" `in_` (rawopts_ opts) = putStrLn $ binaryfilename progname
        | null cmd                                        = putStr $ showModeHelp mainmode'
        | cmd `isPrefixOf` "add"                          = showModeHelpOr addmode      $ journalFilePathFromOpts opts >>= ensureJournalFile >> withJournalDo opts add
diff --git a/Hledger/Cli/Options.hs b/Hledger/Cli/Options.hs
--- a/Hledger/Cli/Options.hs
+++ b/Hledger/Cli/Options.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE TemplateHaskell #-}
 {-|
 
 Command-line options for the hledger program, and option-parsing utilities.
@@ -25,9 +26,6 @@
 import Hledger.Cli.Version
 
 
-progname = "hledger"
-progversion = progversionstr progname
-
 -- 1. cmdargs mode and flag definitions, for the main and subcommand modes.
 -- Flag values are parsed initially to simple RawOpts to permit reuse.
 
@@ -428,10 +426,10 @@
 journalFilePathFromOpts :: CliOpts -> IO String
 journalFilePathFromOpts opts = do
   f <- myJournalPath
-  return $ errorIfContainsTilde $ fromMaybe f $ file_ opts
-
-errorIfContainsTilde s |'~' `elem` s = error' "unsupported literal ~ found in environment variable, please adjust"
-                       | otherwise   = s
+  let f' = fromMaybe f $ file_ opts
+  if '~' `elem` f'
+   then error' $ printf "~ in the journal file path is not supported, please adjust (%s)" f'
+   else return f'
 
 aliasesFromOpts :: CliOpts -> [(AccountName,AccountName)]
 aliasesFromOpts = map parseAlias . alias_
@@ -445,7 +443,7 @@
             alias' = case alias of ('=':rest) -> rest
                                    _ -> orig
 
-showModeHelp = showText defaultWrap . helpText HelpFormatDefault
+showModeHelp = showText defaultWrap . helpText [] HelpFormatDefault
 
 tests_Hledger_Cli_Options = TestList
  [
diff --git a/Hledger/Cli/Version.hs b/Hledger/Cli/Version.hs
--- a/Hledger/Cli/Version.hs
+++ b/Hledger/Cli/Version.hs
@@ -1,61 +1,40 @@
-{-# LANGUAGE CPP #-}
+{-# LANGUAGE CPP, TemplateHaskell #-}
 {-
-Version-related utilities. See the Makefile for details of our version
-numbering policy.
+Version number-related utilities. See also the Makefile.
 -}
 
 module Hledger.Cli.Version (
-                            version
-                           ,progversionstr
-                           ,binaryfilename
+  progname,
+  version,
+  prognameandversion,
+  binaryfilename
 )
 where
-import Data.List
+import Distribution.PackageDescription.TH (packageVariable, package, pkgName, pkgVersion)
 import System.Info (os, arch)
 import Text.Printf
 
 import Hledger.Utils
 
 
--- version and PATCHLEVEL are set by the make process
-
-version :: String
-version       = "0.16.1"
+-- package name and version from the cabal file
+progname, version, prognameandversion :: String
+progname = $(packageVariable (pkgName . package))
+version  = $(packageVariable (pkgVersion . package))
+prognameandversion = progname ++ " " ++ version
 
+-- developer build version strings include PATCHLEVEL (number of
+-- patches since the last tag). If defined, it must be a number.
 patchlevel :: String
 #ifdef PATCHLEVEL
-patchlevel = "." ++ show (PATCHLEVEL :: Int) -- must be numeric !
+patchlevel = "." ++ show (PATCHLEVEL :: Int)
 #else
 patchlevel = ""
 #endif
 
+-- the package version plus patchlevel if specified
 buildversion :: String
-buildversion  = version ++ patchlevel :: String
-
--- | Given a program name, return a human-readable version string.  For
--- development builds, at least non-cabal builds, the patch level (ie the
--- number of patches applied since last release tag) will also be
--- included.
-progversionstr :: String -> String
-progversionstr progname = progname ++ "-" ++ versionstr ++ configmsg
-    where
-      versionstr = prettify $ splitAtElement '.' buildversion
-          where
-            prettify (major:minor:bugfix:patches:[]) =
-                printf "%s.%s%s%s" major minor bugfix' patches'
-                    where
-                      bugfix'
-                          | bugfix `elem` ["0"{-,"98","99"-}] = ""
-                          | otherwise = '.' : bugfix
-                      patches'
-                          | patches/="0" = "+"++patches
-                          | otherwise = ""
-            prettify s = intercalate "." s
-
-      configmsg | null buildflags = ""
-                | otherwise       = " with " ++ intercalate ", " buildflags
-
-      buildflags = []
+buildversion  = version ++ patchlevel
 
 -- | Given a program name, return a precise platform-specific executable
 -- name suitable for naming downloadable binaries.  Can raise an error if
diff --git a/hledger.cabal b/hledger.cabal
--- a/hledger.cabal
+++ b/hledger.cabal
@@ -1,5 +1,5 @@
 name:           hledger
-version: 0.16.1
+version: 0.17
 category:       Finance
 synopsis:       The main command-line interface for the hledger accounting tool.
 description:
@@ -17,7 +17,7 @@
 homepage:       http://hledger.org
 bug-reports:    http://code.google.com/p/hledger/issues
 stability:      beta
-tested-with:    GHC==6.12, GHC==7.0
+tested-with:    GHC==7.0, GHC==7.2
 cabal-version:  >= 1.8
 build-type:     Simple
 -- data-dir:       data
@@ -35,6 +35,10 @@
   type:     darcs
   location: http://joyful.com/repos/hledger
 
+flag threaded
+    Description:   Build with support for multithreaded execution
+    Default:       True
+
 library
   -- XXX should set patchlevel here as in Makefile
   cpp-options:    -DPATCHLEVEL=0
@@ -57,10 +61,11 @@
                   Hledger.Cli.Stats
   -- should be the same as below
   build-depends:
-                  hledger-lib == 0.16.1
+                  hledger-lib == 0.17
                  ,base >= 3 && < 5
+                 ,cabal-file-th
                  ,containers
-                 ,cmdargs >= 0.8   && < 0.9
+                 ,cmdargs >= 0.9.1   && < 0.10
                  ,csv
                  ,directory
                  ,filepath
@@ -104,13 +109,16 @@
                   Hledger.Cli.Stats
   -- XXX should set patchlevel here as in Makefile
   cpp-options:    -DPATCHLEVEL=0
-  ghc-options:    -threaded -W
-  -- should be the same as above
+  ghc-options:    -W
+  if flag(threaded)
+       ghc-options:   -threaded
+ -- should be the same as above
   build-depends:
-                  hledger-lib == 0.16.1
+                  hledger-lib == 0.17
                  ,base >= 3 && < 5
+                 ,cabal-file-th
                  ,containers
-                 ,cmdargs >= 0.8   && < 0.9
+                 ,cmdargs >= 0.9.1   && < 0.10
                  ,csv
                  ,directory
                  ,filepath
