Refactored command line code.