cf_layer = arcpy.na.MakeClosestFacilityLayer(
        network_dataset, NA_LAYER, impedance_attribute, travel_direction,
        converted_cutoff, num_facilities_to_find, accumulate_attributes_to_use,
        uturn_policy, restrictions_to_use, use_hierarchy, None, route_shape,
        time_of_day, time_of_day_usage).getOutput(0)
    cf_layer_exists = True
    na_class_names = arcpy.na.GetNAClassNames(cf_layer)
    solver_props = arcpy.na.GetSolverProperties(cf_layer)

    #Set time zone usage if time of day is specified
    if time_of_day:
        solver_props.timeZoneUsage = time_zone_usage

    #Add attribute parameters if specified
    nau.update_attribute_parameters(
        cf_layer, attribute_parameters, restrictions_to_use +
        accumulate_attributes_to_use + [impedance_attribute],
        desc_nds_attributes)
    #Add Barriers before loading facilities and incidents as we want to exclude restricted portions
    if load_point_barriers:
        #point_barrier_fields = arcpy.ListFields(point_barriers)
        nau.add_locations(cf_layer, "Barriers", point_barriers_obj,
                          impedance_attribute, impedance_units,
                          measurement_units, max_snap_tolerance,
                          feature_locator_where_clause, measurement_method)
    if load_line_barriers:
        #line_barrier_fields = arcpy.ListFields(line_barriers)
        nau.add_locations(cf_layer, "PolylineBarriers", line_barriers_obj,
                          impedance_attribute, impedance_units,
                          measurement_units, max_snap_tolerance,
                          feature_locator_where_clause, measurement_method)
    if load_polygon_barriers:
                                  restrictions_to_use, trimPolygons, polygonTrimDistance,
                                  "NO_LINES_SOURCE_FIELDS", useHierarchy, arriveDepartTime).getOutput(0)
    
    saLayerExists = True
    saLayerSolverProps = arcpy.na.GetSolverProperties(saLayer)
    #Set the timeZoneUsage if timeOfDay is specified
    if arriveDepartTime:
        saLayerSolverProps.timeZoneUsage = timeZoneUsage
    
    #Add FacilityOID field that will contain the ObjectdID from input points
    #arcpy.na.AddFieldToAnalysisLayer(saLayer, naClassNames["Facilities"], saFacilitiesOIDFieldName, "LONG",
                                     #field_alias=saFacilitiesOIDFieldName)
    
    
    #Add attribute parameters if specified
    nau.update_attribute_parameters(saLayer, attributeParameters, restrictions_to_use + [impedanceAttribute], descNDSAttributes)    

    #Add Barriers before loading facilities as we want to exclude restricted portions
    if loadPointBarriers:
        nau.add_locations(saLayer, "Barriers", point_barriers_obj, impedanceAttribute, impedanceUnit,
                          breakUnits, searchTolerance, locatorWhereClause)        
    if loadLineBarriers:
        nau.add_locations(saLayer, "PolylineBarriers", line_barriers_obj, impedanceAttribute, impedanceUnit,
                          breakUnits, searchTolerance, locatorWhereClause)        
    
    if loadPolygonBarriers:
        nau.add_locations(saLayer, "PolygonBarriers", polygon_barriers_obj, impedanceAttribute, impedanceUnit,
                          breakUnits, searchTolerance, locatorWhereClause)        
    
    #Add facilities
    nau.add_locations(saLayer, "Facilities", facilities_obj, impedanceAttribute, impedanceUnit,
        route_shape,
        time_of_day,
        time_of_day_usage,
    ).getOutput(0)
    cf_layer_exists = True
    na_class_names = arcpy.na.GetNAClassNames(cf_layer)
    solver_props = arcpy.na.GetSolverProperties(cf_layer)

    # Set time zone usage if time of day is specified
    if time_of_day:
        solver_props.timeZoneUsage = time_zone_usage

    # Add attribute parameters if specified
    nau.update_attribute_parameters(
        cf_layer,
        attribute_parameters,
        restrictions_to_use + accumulate_attributes_to_use + [impedance_attribute],
        desc_nds_attributes,
    )
    # Add Barriers before loading facilities and incidents as we want to exclude restricted portions
    if load_point_barriers:
        # point_barrier_fields = arcpy.ListFields(point_barriers)
        nau.add_locations(
            cf_layer,
            "Barriers",
            point_barriers_obj,
            impedance_attribute,
            impedance_units,
            measurement_units,
            max_snap_tolerance,
            feature_locator_where_clause,
            measurement_method,
        uturnPolicy, restrictions_to_use, trimPolygons, polygonTrimDistance,
        "NO_LINES_SOURCE_FIELDS", useHierarchy, arriveDepartTime).getOutput(0)

    saLayerExists = True
    saLayerSolverProps = arcpy.na.GetSolverProperties(saLayer)
    #Set the timeZoneUsage if timeOfDay is specified
    if arriveDepartTime:
        saLayerSolverProps.timeZoneUsage = timeZoneUsage

    #Add FacilityOID field that will contain the ObjectdID from input points
    #arcpy.na.AddFieldToAnalysisLayer(saLayer, naClassNames["Facilities"], saFacilitiesOIDFieldName, "LONG",
    #field_alias=saFacilitiesOIDFieldName)

    #Add attribute parameters if specified
    nau.update_attribute_parameters(saLayer, attributeParameters,
                                    restrictions_to_use + [impedanceAttribute],
                                    descNDSAttributes)

    #Add Barriers before loading facilities as we want to exclude restricted portions
    if loadPointBarriers:
        nau.add_locations(saLayer, "Barriers", point_barriers_obj,
                          impedanceAttribute, impedanceUnit, breakUnits,
                          searchTolerance, locatorWhereClause)
    if loadLineBarriers:
        nau.add_locations(saLayer, "PolylineBarriers", line_barriers_obj,
                          impedanceAttribute, impedanceUnit, breakUnits,
                          searchTolerance, locatorWhereClause)

    if loadPolygonBarriers:
        nau.add_locations(saLayer, "PolygonBarriers", polygon_barriers_obj,
                          impedanceAttribute, impedanceUnit, breakUnits,