Fixed some bugs, simplified command line parsing