added 'mode' parameter to speed up. Setting default numGen to 1e6