added argument for setting number of threads. revampled arg parsing