Added a Command class

Added a Command class to make the code more modular and to shorten the
content of Main