Added a sanity check to make sure that the stored num_tasks is correct