Fix ensure_num_units