Added command reading in main. Fix parsing bugs in command-factory