${ImageMagick_LIBRARIES}
        json-c)
 
+IF(CMAKE_BUILD_TYPE STREQUAL "Release")
+       add_compile_definitions("NODEBUG")
+ENDIF()
+
 INSTALL(TARGETS "sane-kds_s2000w_net" "sane-kds_s2000w_net-static"
        DESTINATION ${CMAKE_LIBRARY_PATH}/sane)
 install(FILES "kds_s2000w_net.conf"
 
 #include "kds_s2000w_config.h"
 #include "kds_s2000w_heartbeat.h"
 #include "kds_s2000w_client.h"
+
+#ifndef NODEBUG
 #include "kds_s2000w_debug.h"
+#endif
 
 void _kds_s2000w_client_read_error_status(CURL* curl, response* resp)
 {
 
 void _kds_s2000w_client_stream_to_response(FILE* stream, response* resp, size_t* size)
 {
+#ifndef NODEBUG
        debug_printf(ALL, "kds_s2000w_client_stream_to_response");
+#endif
 
        resp->data = realloc(resp->data, sizeof(char) * *size + 1);
        fseek(stream, 0, SEEK_SET);
 
 response* kds_s2000w_client_response_init()
 {
+#ifndef NODEBUG
        debug_printf(ALL, "kds_s2000w_client_response_init");
+#endif
 
        response* resp = NULL;
 
 
 void kds_s2000w_client_response_free(response* response)
 {
+#ifndef NODEBUG
        debug_printf(ALL, "kds_s2000w_client_response_free");
+#endif
        if (response == NULL)
                return;
 
 
 int kds_s2000w_client_open_session(response* response)
 {
+#ifndef NODEBUG
        debug_printf(ALL, "kds_s2000w_client_open_session");
+#endif
+
        _kds_s2000w_client_load_config();
 
        CURL* curl = NULL;
 
 void kds_s2000w_client_close_session(int64_t sessionid)
 {
+#ifndef NODEBUG
        debug_printf(ALL, "kds_s2000w_client_close_session");
+#endif
+
        CURL* curl = NULL;
        CURLU* url_handler = NULL;
        struct curl_slist* headers = NULL;
 
 int kds_s2000w_client_status_session(int64_t sessionid, response* response)
 {
+#ifndef NODEBUG
        debug_printf(ALL, "kds_s2000w_client_status_session");
+#endif
+
        join_thread();
        wait_seconds(&p_config.heartbeat);
        CURL* curl = NULL;
 
 int kds_s2000w_client_start_scan(int64_t sessionid, response* response)
 {
+#ifndef NODEBUG
        debug_printf(ALL, "kds_s2000w_client_start_scan");
+#endif
+
        CURL* curl = NULL;
        CURLU* url_handler = NULL;
        char* url = NULL;
 
 int kds_s2000w_client_stop_scan(int64_t sessionid, response* response)
 {
+#ifndef NODEBUG
        debug_printf(ALL, "kds_s2000w_client_stop_scan");
+#endif
+
        CURL* curl = NULL;
        CURLU* url_handler = NULL;
        struct curl_slist* headers = NULL;
 
 int kds_s2000w_client_get_image(int64_t sessionid, int img_number, response* response)
 {
+#ifndef NODEBUG
        debug_printf(ALL, "kds_s2000w_client_get_image");
+#endif
+
        CURL* curl = NULL;
        CURLU* url_handler = NULL;
        struct curl_slist* headers = NULL;
 
 int kds_s2000w_client_delete_image(int64_t sessionid, int img_number, response* response)
 {
+#ifndef NODEBUG
        debug_printf(ALL, "kds_s2000w_client_delete_image");
+#endif
+
        CURL* curl = NULL;
        CURLU* url_handler = NULL;
        char* url = NULL;
 
 int kds_s2000w_client_get_capabilities(response* response)
 {
+#ifndef NODEBUG
        debug_printf(ALL, "kds_s2000w_client_get_capabilities");
+#endif
+
        CURL* curl = NULL;
        CURLU* url_handler =NULL;
        char* url = NULL;
 
 int kds_s2000w_client_get_option(int64_t sessionid, response* response)
 {
+#ifndef NODEBUG
        debug_printf(ALL, "kds_s2000w_client_get_option");
+#endif
+
        CURL* curl = NULL;
        CURLU* url_handler = NULL;
        struct curl_slist* headers = NULL;
 
 int kds_s2000w_client_set_option(int64_t sessionid, response* response)
 {
+#ifndef NODEBUG
        debug_printf(ALL, "kds_s2000w_client_set_option");
+#endif
+
        CURL* curl = NULL;
        CURLU* url_handler = NULL;
        char* url = NULL;
 
+#ifndef NODEBUG
 #include <stdio.h>
 #include <stdlib.h>
 #include "kds_s2000w_debug.h"
 {
        if (level <= _get_log_level())
                printf("%s: %hhx\n", message, value);
-}
\ No newline at end of file
+}
+#endif
\ No newline at end of file
 
+#ifndef NODEBUG
 #ifndef KDS_S2000w_DEBUG_H
 #define KDS_S2000w_DEBUG_H
 
 void debug_printf_int(int level, const char* message, int value);
 void debug_printf_long(int level, const char* message, long value);
 void debug_printf_hex(int level, const char* message, char value);
-#endif
\ No newline at end of file
+#endif /* KDS_S2000w_DEBUG_H */
+#endif /* NODEBUG */
\ No newline at end of file
 
 #include "kds_s2000w_handler_opts.h"
 #include "kds_s2000w_client.h"
 #include "kds_s2000w_image_converter.h"
+
+#ifndef NODEBUG
 #include "kds_s2000w_debug.h"
+#endif
 
 void _get_current_metadata(handler* h)
 {
+#ifndef NODEBUG
        debug_printf(ALL, "get_current_metadata");
+#endif
+
        json_object* metadata = NULL;
        json_object* config = NULL;
        blobdata* scanner_image = NULL;
                kds_s2000w_convert_tiff_to_pnm(scanner_image, pnm_image);
        }
 
+#ifndef NODEBUG
        debug_printf_int(DEBUG, "size of pnm image", h->pnm_image->size);
+#endif
 
        if (h->current_metadata->depth == 1)
                h->current_metadata->bytes_per_line = h->current_metadata->channels * floor((h->current_metadata->pixels_per_line + 7) / 8);
 
 void _delete_current_image(handler* h)
 {
+#ifndef NODEBUG
        debug_printf(ALL, "delete_current_image");
+#endif
+
        response* resp = NULL;
 
        resp = kds_s2000w_client_response_init();
 
 void _download_current_image(handler* h)
 {
+#ifndef NODEBUG
        debug_printf(ALL, "download_current_image");
+#endif
+
        response* resp = NULL;
 
        if (h->scanner_image->size > 0) {
 
 void _get_current_scan_status(handler* h)
 {
+#ifndef NODEBUG
        debug_printf(ALL, "get_current_scan_status");
+#endif
+
        json_object* status_resp_obj = NULL;
        json_object* status_obj = NULL;
        json_object* status_value_obj = NULL;
        if (resp->error_size > 0)
                fprintf(stderr, "%s\n", resp->error_status);
 
+#ifndef NODEBUG
        debug_printf(DEBUG, resp->data);
+#endif
+
        status_resp_obj = json_tokener_parse(resp->data);
        status_obj = json_object_object_get(status_resp_obj, "Status");
        status_value_obj = json_object_object_get(status_obj, "NumImagesStored");
 
 handler* init_handler()
 {
+#ifndef NODEBUG
        debug_printf(ALL, "init handler");
+#endif
+
        handler* h = malloc(sizeof(handler));
        h->current_scanner_config = NULL;
        h->current_scan_status = malloc(sizeof(scanstatus));
 
 void free_handler(handler* h)
 {
+#ifndef NODEBUG
        debug_printf(ALL, "free handler");
+#endif
+
        json_object_put(h->current_scanner_config);
        h->current_scanner_config = NULL;
        free(h->current_scan_status);
 
 void reset_handler(handler* h)
 {
+#ifndef NODEBUG
        debug_printf(ALL, "reset handler");
+#endif
+
        free(h->pnm_image->data);
        h->pnm_image->data = NULL;
        free(h->scanner_image->data);
                value_object = NULL;
                json_object_put(sessionJson);
                sessionJson = NULL;
+
+#ifndef NODEBUG
                debug_printf_long(INFO, "SessionId", h->sessionid);
+#endif
 
                // set old config parameters
                kds_s2000w_client_response_free(resp);
 
 void kds_s2000w_handler_open(const char* devicename, void** handle)
 {
+#ifndef NODEBUG
        debug_printf(ALL, "kds_s2000w_handler_open");
+#endif
+
        if (strcmp(devicename, "kds_s2000w_net") != 0)
                return;
 
                json_object_object_get_ex(h->current_scanner_config, "SessionId", &value_object);
                h->sessionid = json_object_get_int64(value_object);
                h->state = OPENED;
+#ifndef NODEBUG
                debug_printf_long(INFO, "SessionId", h->sessionid);
+#endif
                value_object = NULL;
        }
 
 
 void kds_s2000w_handler_close(handler* h)
 {
+#ifndef NODEBUG
        debug_printf(ALL, "kds_s2000w_handler_close");
+#endif
+
        json_object_put(h->current_scanner_config);
        h->current_scanner_config = NULL;
 
 
 void kds_s2000w_handler_start_scan(handler* h)
 {
+#ifndef NODEBUG
        debug_printf(ALL, "kds_s2000w_handler_start_scan");
+#endif
+
        response* resp = NULL;
 
        resp = kds_s2000w_client_response_init();
 
 void kds_s2000w_handler_stop_scan(handler* h)
 {
+#ifndef NODEBUG
        debug_printf(ALL, "kds_s2000w_handler_stop_scan");
+#endif
+
        response* resp = NULL;
 
        resp = kds_s2000w_client_response_init();
 
 void kds_s2000w_handler_get_parameters(handler* h)
 {
+#ifndef NODEBUG
        debug_printf(ALL, "kds_s2000w_handler_get_parameters");
+#endif
 
        if (h->current_scan_status->complete_scanned
                && h->current_scan_status->available_images <= 0) {
                return;
        }
 
+#ifndef NODEBUG
        debug_printf(DEBUG, "get scanner status");
+#endif
        _get_current_scan_status(h);
 
+#ifndef NODEBUG
        debug_printf_int(DEBUG, "available images", h->current_scan_status->available_images);
+#endif
        if (h->current_scan_status->available_images > 0) {
+#ifndef NODEBUG
                debug_printf_int(DEBUG, "download image", h->current_scan_status->current_image_number);
+#endif
                _download_current_image(h);
+#ifndef NODEBUG
                debug_printf_int(DEBUG, "get metadata for image", h->current_scan_status->current_image_number);
+#endif
                _get_current_metadata(h);
+#ifndef NODEBUG
                debug_printf_int(DEBUG, "delete image", h->current_scan_status->current_image_number);
+#endif
                _delete_current_image(h);
                h->current_scan_status->current_image_number++;
        }
 
 #include "kds_s2000w_handler.h"
 #include "kds_s2000w_client.h"
 #include "kds_s2000w_handler_opts.h"
+
+#ifndef NODEBUG
 #include "kds_s2000w_debug.h"
+#endif
 
 #define AUTOSTART_ALWAYS_ON 1
 #define COUNT_CUSTOM_OPTIONS 0
        h->current_scanner_config = json_tokener_parse(resp->data);
 
        if (result != 0 || resp->code != 200) {
+#ifndef NODEBUG
                debug_printf_int(ERROR, "load options response code", resp->code);
+#endif
                kds_s2000w_client_response_free(resp);
                resp = NULL;
                json_object_put(h->current_scanner_config);
                        config = json_object_object_get(h->current_scanner_config, "Configuration");
                        int* int_value_ptr = (int*) value;
                        *int_value_ptr = json_object_object_length(config) + COUNT_CUSTOM_OPTIONS;
+#ifndef NODEBUG
                        debug_printf_int(DEBUG, "option numbers", *int_value_ptr);
+#endif
                        break;
                case 2:
                        value_object = json_object_object_get(config, "ScanSource");
                        resp->data = realloc(resp->data, resp->size);
                        resp->data = memcpy(resp->data, json_string, resp->size);
                        kds_s2000w_client_set_option(h->sessionid, resp);
+#ifndef NODEBUG
                        if (resp->code != 200)
                                debug_printf_int(ERROR, "set options response code", resp->code);
+#endif
 
                        kds_s2000w_client_response_free(resp);
                        resp = NULL;
        resp->data = realloc(resp->data, resp->size);
        resp->data = memcpy(resp->data, json_string, resp->size);
        kds_s2000w_client_set_option(h->sessionid, resp);
+#ifndef NODEBUG
        if (resp->code != 200)
                debug_printf_int(ERROR, "set options response code", resp->code);
+#endif
 
        kds_s2000w_client_response_free(resp);
        resp = NULL;
 
 #include <string.h>
 #include <magick/MagickCore.h>
 #include "kds_s2000w_image_converter.h"
+
+#ifndef NODEBUG
 #include "kds_s2000w_debug.h"
+#endif
 
 void kds_s2000w_convert_to_pnm_with_depth(blobdata* in,
        blobdata* out,
        int depth,
        const char* format)
 {
+#ifndef NODEBUG
        debug_printf(ALL, "kds_s2000w_convert_to_pnm_With_depth");
+#endif
        
        ExceptionInfo* exception = NULL;
        Image* input_image = NULL;
        image_info = CloneImageInfo(NULL);
 
        sprintf(image_info->filename, "streamin.%s", format);
+
+#ifndef NODEBUG
        debug_printf(DEBUG, image_info->filename);
+#endif
+
        input_image = BlobToImage(image_info, in->data, in->size , exception);
 
        if (exception->severity != UndefinedException) {
 
 void kds_s2000w_convert_jpg_to_pnm_with_depth(blobdata* in, blobdata* out, int depth)
 {
+#ifndef NODEBUG
        debug_printf(ALL, "kds_s2000w_convert_jpg_to_pnm_With_depth");
+#endif
+
        const char* extension = "jpg";
        kds_s2000w_convert_to_pnm_with_depth(in, out, depth, extension);
 }
 
 void kds_s2000w_convert_tiff_to_pnm(blobdata* in, blobdata* out)
 {
-       const char* extension = "tiff";
+#ifndef NODEBUG
        debug_printf(ALL, "kds_s2000w_convert_tiff_to_pnm");
+#endif
+
+       const char* extension = "tiff";
        kds_s2000w_convert_to_pnm_with_depth(in, out, -1, extension);
 }
 
 void kds_s2000w_metadata_from_image(blobdata* image, image_metadata* mdata)
 {
+#ifndef NODEBUG
        debug_printf(ALL, "kds_s2000w_metadata_from_image");
+#endif
+
        ExceptionInfo* exception = NULL;
        Image* input_image = NULL;
        ImageInfo* image_info = NULL;
 
 #include "kds_s2000w_net.h"
 #include "kds_s2000w_option_descriptors.h"
 #include "kds_s2000w_handler.h"
+
+#ifndef NODEBUG
 #include "kds_s2000w_debug.h"
+#endif
 
 int _sane_kds_s2000w_net_find_first_data_byte(imagedata* image)
 {
+#ifndef NODEBUG
        debug_printf(ALL, "sane_kds_s2000w_net_find_first_data_byte");
+#endif
+
        char* data = image->data;
        int header_spaces = 3;
 
 
 SANE_Status _sane_kds_s2000w_net_init(SANE_Int* version_code, SANE_Auth_Callback authorize)
 {
+#ifndef NODEBUG
        debug_printf(ALL, "sane_kds_s2000w_net_init");
+#endif
+
        *version_code = SANE_VERSION_CODE(MAJOR, MINOR, PATCH);
        kds_s2000w_option_descriptor_init_option_descriptors();
        return SANE_STATUS_GOOD;
 
 void _sane_kds_s2000w_net_exit(void)
 {
+#ifndef NODEBUG
        debug_printf(ALL, "sane_kds_s2000w_net_exit");
+#endif
 }
 
 SANE_Status _sane_kds_s2000w_net_get_devices(SANE_Device*** device_list,
        SANE_Bool local_only)
 {
+#ifndef NODEBUG
        debug_printf(ALL, "sane_kds_s2000w_net_get_devices");
+#endif
+
        SANE_Device** own_device_list = NULL;
        SANE_Device* device_info = NULL;
        if (local_only)
 SANE_Status _sane_kds_s2000w_net_open(SANE_String_Const devicename,
        SANE_Handle* handle)
 {
+#ifndef NODEBUG
        debug_printf(ALL, "sane_kds_s2000w_net_open");
+#endif
+
        if (strcmp(devicename, "kds_s2000w_net") != 0)
                return SANE_STATUS_INVAL;
 
 
 void _sane_kds_s2000w_net_close(SANE_Handle handle)
 {
+#ifndef NODEBUG
        debug_printf(ALL, "sane_kds_s2000w_net_close");
+#endif
+
        kds_s2000w_option_descriptor_free_option_descriptors();
        kds_s2000w_handler_close(handle);
 }
 const SANE_Option_Descriptor* _sane_kds_s2000w_net_get_option_descriptor(
        SANE_Handle handle, SANE_Int option)
 {
+#ifndef NODEBUG
        debug_printf(ALL, "sane_kds_s2000w_net_get_option_descriptor");
+#endif
+
        return kds_s2000w_option_get_descriptor(option);
 }
 
 SANE_Status _sane_kds_s2000w_net_control_option(SANE_Handle handle,
        SANE_Int option, SANE_Action action, void* value, SANE_Int* info)
 {
+#ifndef NODEBUG
        debug_printf(ALL, "sane_kds_s2000w_net_control_option");
+#endif
+
        handler* h = (handler*) handle;
        if (action == SANE_ACTION_GET_VALUE)
                kds_s2000w_handler_get_option(h, option, value, info);
 
 void _sane_kds_s2000w_net_cancel(SANE_Handle handle)
 {
+#ifndef NODEBUG
        debug_printf(ALL, "sane_kds_s2000w_net_cancel");
+#endif
+
        handler* h = (handler*) handle;
        h->read_info->cancel = 1;
        kds_s2000w_handler_stop_scan(h);
 SANE_Status _sane_kds_s2000w_net_get_parameters(SANE_Handle handle,
        SANE_Parameters* params)
 {
+#ifndef NODEBUG
        debug_printf(ALL, "sane_kds_s2000w_net_get_parameters");
+#endif
+
        handler* h = (handler*) handle;
 
        if (h->read_info->cancel) {
        h->read_info->readed_bytes_per_line = 0;
        h->read_info->readed_lines = 0;
 
+#ifndef NODEBUG
        debug_printf_int(DEBUG, "format", params->format);
        debug_printf_int(DEBUG, "last frame", params->last_frame);
        debug_printf_int(DEBUG, "bytes per line", params->bytes_per_line);
        debug_printf_int(DEBUG, "pixels per line", params->pixels_per_line);
        debug_printf_int(DEBUG, "lines", params->lines);
        debug_printf_int(DEBUG, "depth", params->depth);
+#endif
 
        return SANE_STATUS_GOOD;
 }
 
 SANE_Status _sane_kds_s2000w_net_start(SANE_Handle handle)
 {
+#ifndef NODEBUG
        debug_printf(ALL, "sane_kds_s2000w_net_start");
+#endif
+
        handler* h = (handler*) handle;
 
        if (h->read_info->cancel) {
 SANE_Status _sane_kds_s2000w_net_read(SANE_Handle handle, SANE_Byte* data,
        SANE_Int max_length, SANE_Int* length)
 {
+#ifndef NODEBUG
        debug_printf(ALL, "sane_kds_s2000w_net_read");
+#endif
+
        handler* h = (handler*) handle;
 
        // cancel
 SANE_Status _sane_kds_s2000w_net_set_io_mode(SANE_Handle handle,
        SANE_Bool non_blocking)
 {
+#ifndef NODEBUG
        debug_printf(ALL, "sane_kds_s2000w_net_set_io_mode");
+#endif
+
        return SANE_STATUS_UNSUPPORTED;
 }
 
 SANE_Status _sane_kds_s2000w_net_get_select_fd(SANE_Handle handle, SANE_Int* fd)
 {
+#ifndef NODEBUG
        debug_printf(ALL, "sane_kds_s2000w_net_get_select_fd");
+#endif
+
        return SANE_STATUS_UNSUPPORTED;
 }
\ No newline at end of file
 
 #include <stdlib.h>
 #include <sane/saneopts.h>
 #include "kds_s2000w_option_descriptors.h"
+
+#ifndef NODEBUG
 #include "kds_s2000w_debug.h"
+#endif
 
 SANE_Option_Descriptor* descriptor_array = NULL;
 
 
 SANE_Option_Descriptor _kds_s2000w_option_descriptor_standard_group()
 {
+#ifndef NODEBUG
        debug_printf(ALL, "kds_s2000w_option_descriptor_standard_group");
+#endif
 
        SANE_Option_Descriptor descriptor = {
                SANE_NAME_STANDARD,
 
 SANE_Option_Descriptor _kds_s2000w_option_descriptor_geometry_group()
 {
+#ifndef NODEBUG
        debug_printf(ALL, "kds_s2000w_option_descriptor_scan_area_group");
+#endif
+
        SANE_Option_Descriptor descriptor = {
                SANE_NAME_GEOMETRY,
                SANE_TITLE_GEOMETRY,
 
 SANE_Option_Descriptor _kds_s2000w_option_descriptor_num_options()
 {
+#ifndef NODEBUG
        debug_printf(ALL, "kds_s2000w_option_descriptor_num_options");
+#endif
 
        SANE_Option_Descriptor descriptor = {
                SANE_NAME_NUM_OPTIONS,
 
 SANE_Option_Descriptor _kds_s2000w_option_descriptor_dpi()
 {
+#ifndef NODEBUG
        debug_printf(ALL, "kds_s2000w_option_descriptor_dpi");
+#endif
 
        SANE_Option_Descriptor descriptor = {
                SANE_NAME_SCAN_RESOLUTION,
 
 SANE_Option_Descriptor _kds_s2000w_option_descriptor_scanside()
 {
+#ifndef NODEBUG
        debug_printf(ALL, "kds_s2000w_option_descriptor_scanside");
+#endif
 
        constraint_scanside = malloc(sizeof(SANE_String_Const*) * 3);
        constraint_scanside[0] = "Simplex";
 
 SANE_Option_Descriptor _kds_s2000w_option_descriptor_color_mode()
 {
+#ifndef NODEBUG
        debug_printf(ALL, "kds_s2000w_option_descriptor_color_mode");
+#endif
 
        constraint_colormode = malloc(sizeof(SANE_String_Const*) * 4);
        constraint_colormode[0] = "Color";
 
 SANE_Option_Descriptor _kds_s2000w_option_descriptor_skip_blank_pages()
 {
+#ifndef NODEBUG
        debug_printf(ALL, "kds_s2000w_option_descriptor_skip_blank_pages");
+#endif
 
        SANE_Option_Descriptor descriptor = {
                "skip-blank-pages",
 
 SANE_Option_Descriptor _kds_s2000w_option_descriptor_color_drop()
 {
+#ifndef NODEBUG
        debug_printf(ALL, "kds_s2000w_option_descriptor_color_drop");
+#endif
 
        constraint_colordrop = malloc(sizeof(SANE_String_Const*) * 9);
        constraint_colordrop[0] = "None";
 
 SANE_Option_Descriptor _kds_s2000w_option_descriptor_color_drop_out_aggressiveness()
 {
+#ifndef NODEBUG
        debug_printf(ALL, "kds_s2000w_option_descriptor_color_drop_out_aggressiveness");
+#endif
 
        SANE_Option_Descriptor descriptor = {
                "colordropoutaggressiveness",
 
 SANE_Option_Descriptor _kds_s2000w_option_descriptor_color_auto_brightness_mode()
 {
+#ifndef NODEBUG
        debug_printf(ALL, "kds_s2000w_option_descriptor_color_auto_brightness_mode");
+#endif
 
        constraint_color_auto_brightnessmode = malloc(sizeof(SANE_String_Const*) * 3);
        constraint_color_auto_brightnessmode[0] = "None";
 
 SANE_Option_Descriptor _kds_s2000w_option_descriptor_color_balance_mode()
 {
+#ifndef NODEBUG
        debug_printf(ALL, "kds_s2000w_option_descriptor_color_balance_mode");
+#endif
 
        constraint_color_balance_mode = malloc(sizeof(SANE_String_Const*) * 5);
        constraint_color_balance_mode[0] = "None";
 
 SANE_Option_Descriptor _kds_s2000w_option_descriptor_color_balancea_agressiveness()
 {
+#ifndef NODEBUG
        debug_printf(ALL, "kds_s2000w_option_descriptor_color_balancea_agressiveness");
+#endif
 
        SANE_Option_Descriptor descriptor = {
                "colorbalanceaggressiveness",
 
 SANE_Option_Descriptor _kds_s2000w_option_descriptor_color_balance_red()
 {
+#ifndef NODEBUG
        debug_printf(ALL, "kds_s2000w_option_descriptor_color_balance_red");
+#endif
 
        SANE_Option_Descriptor descriptor = {
                "colorbalancered",
 
 SANE_Option_Descriptor _kds_s2000w_option_descriptor_color_balance_green()
 {
+#ifndef NODEBUG
        debug_printf(ALL, "kds_s2000w_option_descriptor_color_balance_green");
+#endif
 
        SANE_Option_Descriptor descriptor = {
                "colorbalancegreen",
 
 SANE_Option_Descriptor _kds_s2000w_option_descriptor_color_balance_blue()
 {
+#ifndef NODEBUG
        debug_printf(ALL, "kds_s2000w_option_descriptor_color_balance_blue");
+#endif
 
        SANE_Option_Descriptor descriptor = {
                "colorbalanceblue",
 
 SANE_Option_Descriptor _kds_s2000w_option_descriptor_foreground_boldness_mode()
 {
+#ifndef NODEBUG
        debug_printf(ALL, "kds_s2000w_option_descriptor_foreground_boldness_mode");
+#endif
 
        constraint_foreground_boldness_mode = malloc(sizeof(SANE_String_Const*) * 4);
        constraint_foreground_boldness_mode[0] = "None";
 
 SANE_Option_Descriptor _kds_s2000w_option_descriptor_foreground_boldness_aggressiveness()
 {
+#ifndef NODEBUG
        debug_printf(ALL, "kds_s2000w_option_descriptor_foreground_boldness_aggressiveness");
+#endif
 
        SANE_Option_Descriptor descriptor = {
                "foreground-boldness-aggressiveness",
 
 SANE_Option_Descriptor _kds_s2000w_option_descriptor_background_smoothing_mode()
 {
+#ifndef NODEBUG
        debug_printf(ALL, "kds_s2000w_option_descriptor_background_smoothing_mode");
+#endif
 
        constraint_background_smoothing_mode = malloc(sizeof(SANE_String_Const*) * 4);
        constraint_background_smoothing_mode[0] = "None";
 
 SANE_Option_Descriptor _kds_s2000w_option_descriptor_background_smoothing_aggressiveness()
 {
+#ifndef NODEBUG
        debug_printf(ALL, "kds_s2000w_option_descriptor_background_smoothing_aggressiveness");
+#endif
 
        SANE_Option_Descriptor descriptor = {
                "background-smoothing-aggressiveness",
 
 SANE_Option_Descriptor _kds_s2000w_option_descriptor_binarization_contrast()
 {
+#ifndef NODEBUG
        debug_printf(ALL, "kds_s2000w_option_descriptor_binarization_contrast");
+#endif
 
        SANE_Option_Descriptor descriptor = {
                SANE_NAME_CONTRAST,
 
 SANE_Option_Descriptor _kds_s2000w_option_descriptor_scan_source()
 {
+#ifndef NODEBUG
        debug_printf(ALL, "kds_s2000w_option_descriptor_scan_source");
+#endif
 
        constraint_scan_source = malloc(sizeof(SANE_String_Const*) * 4);
        constraint_scan_source[0] = "DocumentFeeder";
 
 SANE_Option_Descriptor _kds_s2000w_option_descriptor_config_reset()
 {
+#ifndef NODEBUG
        debug_printf(ALL, "kds_s2000w_option_descriptor_config_reset");
+#endif
 
        SANE_Option_Descriptor descriptor = {
                "config-reset",
 
 void kds_s2000w_option_descriptor_init_option_descriptors()
 {
+#ifndef NODEBUG
        debug_printf(ALL, "kds_s2000w_option_descriptor_init_option_descriptors");
+#endif
 
        descriptor_array = malloc(sizeof(SANE_Option_Descriptor) * MAX_OPTION_COUNT);
        descriptor_array[0] = _kds_s2000w_option_descriptor_num_options();
 
 void kds_s2000w_option_descriptor_free_option_descriptors()
 {
+#ifndef NODEBUG
        debug_printf(ALL, "kds_s2000w_option_descriptor_free_option_descriptors");
+#endif
+
        free(constraint_scanside);
        constraint_scanside = NULL;
        free(constraint_colormode);
 
 SANE_Option_Descriptor* kds_s2000w_option_get_descriptor(int option)
 {
+#ifndef NODEBUG
        debug_printf(ALL, "kds_s2000w_option_get_descriptor");
+#endif
+
        if (option >= MAX_OPTION_COUNT)
                return NULL;