Edit

if (any_unused && sub_ways.size() <= 30) {

if (any_unused && sub_ways.size() <= MAX_SUBWAYS_FOR_RETRY) {