Adding command line options and minor bugfixes.