Refactor of command line tools