MAD_NUM_THREADS=0 was accepted silently, caused segfault; added assert nthreads >=0