Fixed loop_body and do_single_random_task for the case where it returns none.