fix debug output and add command line options