added nthreads option to remaining routines