refactored the command-line parsing and actions
fixed templates and implementation problems