Added the main threshold routine as well as the commandline arguments.