Cleaned some code and added some command line options

Added command line options: shutdown, restart, upgrade