More command line improvements (take 2)

See #2000 for details.