Better handling of number of cores