Index: uspace/lib/usbhid/include/usb/hid/hid_report_items.h
===================================================================
--- uspace/lib/usbhid/include/usb/hid/hid_report_items.h	(revision 14e1bcc46c8957d6c1c7726e8185e23d95ae25be)
+++ uspace/lib/usbhid/include/usb/hid/hid_report_items.h	(revision f3b39b431bddc818b72efc239b05c1caad7fd5c4)
@@ -96,6 +96,5 @@
 #define USB_HID_ITEM_FLAG_RELATIVE(flags) 	((flags & 0x4) == 0x4)
 
-/**
- * Indicates whether the data “rolls over” when reaching either the extreme
+/** Indicates whether the data “rolls over” when reaching either the extreme
  * high or low value. For example, a dial that can spin freely 360 degrees
  * might output values from 0 to 10. If Wrap is indicated, the next value
Index: uspace/lib/usbhid/include/usb/hid/hiddescriptor.h
===================================================================
--- uspace/lib/usbhid/include/usb/hid/hiddescriptor.h	(revision 14e1bcc46c8957d6c1c7726e8185e23d95ae25be)
+++ uspace/lib/usbhid/include/usb/hid/hiddescriptor.h	(revision f3b39b431bddc818b72efc239b05c1caad7fd5c4)
@@ -43,5 +43,5 @@
 
 int usb_hid_parse_report_descriptor(usb_hid_report_t *report, 
-                                    const uint8_t *data, size_t size);
+		const uint8_t *data, size_t size);
 
 void usb_hid_free_report(usb_hid_report_t *report);
@@ -51,20 +51,26 @@
 int usb_hid_report_init(usb_hid_report_t *report);
 
-int usb_hid_report_append_fields(usb_hid_report_t *report, 
-                                 usb_hid_report_item_t *report_item);
+int usb_hid_report_append_fields(usb_hid_report_t *report,
+		usb_hid_report_item_t *report_item);
 
-usb_hid_report_description_t * usb_hid_report_find_description(const usb_hid_report_t *report, uint8_t report_id, usb_hid_report_type_t type);
+usb_hid_report_description_t * usb_hid_report_find_description(
+		const usb_hid_report_t *report, uint8_t report_id,
+		usb_hid_report_type_t type);
 
-int usb_hid_report_parse_tag(uint8_t tag, uint8_t class, const uint8_t *data, size_t item_size,
-                             usb_hid_report_item_t *report_item, usb_hid_report_path_t *usage_path);
+int usb_hid_report_parse_tag(uint8_t tag, uint8_t class, const uint8_t *data,
+		size_t item_size, usb_hid_report_item_t *report_item,
+		usb_hid_report_path_t *usage_path);
 
-int usb_hid_report_parse_main_tag(uint8_t tag, const uint8_t *data, size_t item_size,
-                             usb_hid_report_item_t *report_item, usb_hid_report_path_t *usage_path);
+int usb_hid_report_parse_main_tag(uint8_t tag, const uint8_t *data, 
+		size_t item_size, usb_hid_report_item_t *report_item,
+		usb_hid_report_path_t *usage_path);
 
-int usb_hid_report_parse_global_tag(uint8_t tag, const uint8_t *data, size_t item_size,
-                             usb_hid_report_item_t *report_item, usb_hid_report_path_t *usage_path);
+int usb_hid_report_parse_global_tag(uint8_t tag, const uint8_t *data, 
+		size_t item_size, usb_hid_report_item_t *report_item,
+		usb_hid_report_path_t *usage_path);
 
-int usb_hid_report_parse_local_tag(uint8_t tag, const uint8_t *data, size_t item_size,
-                             usb_hid_report_item_t *report_item, usb_hid_report_path_t *usage_path);
+int usb_hid_report_parse_local_tag(uint8_t tag, const uint8_t *data, 
+		size_t item_size, usb_hid_report_item_t *report_item,
+		usb_hid_report_path_t *usage_path);
 
 void usb_hid_descriptor_print_list(link_t *head);
@@ -74,9 +80,11 @@
 void usb_hid_free_report_list(link_t *head);
 
-usb_hid_report_item_t *usb_hid_report_item_clone(const usb_hid_report_item_t *item);
+usb_hid_report_item_t *usb_hid_report_item_clone(
+		const usb_hid_report_item_t *item);
 
 uint32_t usb_hid_report_tag_data_uint32(const uint8_t *data, size_t size);
 
-usb_hid_report_path_t *usb_hid_report_path_try_insert(usb_hid_report_t *report, usb_hid_report_path_t *cmp_path);
+usb_hid_report_path_t *usb_hid_report_path_try_insert(usb_hid_report_t*report,
+		usb_hid_report_path_t *cmp_path);
 
 
Index: uspace/lib/usbhid/include/usb/hid/hidparser.h
===================================================================
--- uspace/lib/usbhid/include/usb/hid/hidparser.h	(revision 14e1bcc46c8957d6c1c7726e8185e23d95ae25be)
+++ uspace/lib/usbhid/include/usb/hid/hidparser.h	(revision f3b39b431bddc818b72efc239b05c1caad7fd5c4)
@@ -47,42 +47,35 @@
  * Input report parser functions
  */
-/** */
-int usb_hid_parse_report(const usb_hid_report_t *report, const uint8_t *data, 
-                         size_t size, uint8_t *report_id);
+int usb_hid_parse_report(const usb_hid_report_t *report, const uint8_t *data,
+		size_t size, uint8_t *report_id);
 
 /*
  * Output report parser functions
  */
-/** Allocates output report buffer*/
 uint8_t *usb_hid_report_output(usb_hid_report_t *report, size_t *size, 
-                               uint8_t report_id);
+		uint8_t report_id);
 
-/** Frees output report buffer*/
 void usb_hid_report_output_free(uint8_t *output);
 
-/** Returns size of report in items */
-size_t usb_hid_report_size(usb_hid_report_t *report, uint8_t report_id, 
-                           usb_hid_report_type_t type);
+size_t usb_hid_report_size(usb_hid_report_t *report, uint8_t report_id,
+		usb_hid_report_type_t type);
 
-size_t usb_hid_report_byte_size(usb_hid_report_t *report, uint8_t report_id, 
-                           usb_hid_report_type_t type);
+size_t usb_hid_report_byte_size(usb_hid_report_t *report, uint8_t report_id,
+		usb_hid_report_type_t type);
 
 
-/** Makes the output report buffer by translated given data */
-int usb_hid_report_output_translate(usb_hid_report_t *report, uint8_t report_id, 
-                                    uint8_t *buffer, size_t size);
+int usb_hid_report_output_translate(usb_hid_report_t *report, 
+		uint8_t report_id, uint8_t *buffer, size_t size);
 
 
-/** */
-usb_hid_report_field_t *usb_hid_report_get_sibling(usb_hid_report_t *report, 
-                                                   usb_hid_report_field_t *field, 
-                                                   usb_hid_report_path_t *path, 
-                                                   int flags, 
-                                                   usb_hid_report_type_t type);
+/*
+ * Report descriptor structure observing functions
+ */
+usb_hid_report_field_t *usb_hid_report_get_sibling(usb_hid_report_t *report,
+		usb_hid_report_field_t *field, usb_hid_report_path_t *path,
+		int flags, usb_hid_report_type_t type);
 
-/** */
 uint8_t usb_hid_get_next_report_id(usb_hid_report_t *report, 
-                                     uint8_t report_id, 
-                                     usb_hid_report_type_t type);
+		uint8_t report_id, usb_hid_report_type_t type);
 
 #endif
Index: uspace/lib/usbhid/include/usb/hid/hidpath.h
===================================================================
--- uspace/lib/usbhid/include/usb/hid/hidpath.h	(revision 14e1bcc46c8957d6c1c7726e8185e23d95ae25be)
+++ uspace/lib/usbhid/include/usb/hid/hidpath.h	(revision f3b39b431bddc818b72efc239b05c1caad7fd5c4)
@@ -42,10 +42,10 @@
 
 /*---------------------------------------------------------------------------*/
-/**
+/*
  * Flags of usage paths comparison modes.
  *
  */
-/** Wanted usage path must be exactly the same as the searched one.
- * This option cannot be combined with the others. 
+/** Wanted usage path must be exactly the same as the searched one.  This
+ * option cannot be combined with the others. 
  */
 #define USB_HID_PATH_COMPARE_STRICT		0
@@ -57,6 +57,6 @@
 
 /** 
- * Only usage page are compared along the usage path. 
- * This option can be combined with others. 
+ * Only usage page are compared along the usage path.  This option can be
+ * combined with others. 
  */
 #define USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY	2
@@ -101,5 +101,6 @@
 	int depth;	
 
-	/** Report id. Zero is reserved and means that report id is not used. */
+	/** Report id. Zero is reserved and means that report id is not used.
+	 * */
 	uint8_t report_id;
 	
@@ -117,9 +118,9 @@
 void usb_hid_report_path_free(usb_hid_report_path_t *path);
 
-int usb_hid_report_path_set_report_id(usb_hid_report_path_t *usage_path, 
-                                      uint8_t report_id);
+int usb_hid_report_path_set_report_id(usb_hid_report_path_t *usage_path,
+		uint8_t report_id);
 
 int usb_hid_report_path_append_item(usb_hid_report_path_t *usage_path, 
-                                    int32_t usage_page, int32_t usage);
+		int32_t usage_page, int32_t usage);
 
 void usb_hid_report_remove_last_item(usb_hid_report_path_t *usage_path);
@@ -128,10 +129,11 @@
 
 void usb_hid_report_set_last_item(usb_hid_report_path_t *usage_path, 
-                                  int32_t tag, int32_t data);
+		int32_t tag, int32_t data);
 
-int usb_hid_report_compare_usage_path(usb_hid_report_path_t *report_path, 
-                                      usb_hid_report_path_t *path, int flags);
+int usb_hid_report_compare_usage_path(usb_hid_report_path_t *report_path,
+		usb_hid_report_path_t *path, int flags);
 
-usb_hid_report_path_t *usb_hid_report_path_clone(usb_hid_report_path_t *usage_path);
+usb_hid_report_path_t *usb_hid_report_path_clone(
+		usb_hid_report_path_t *usage_path);
 
 void usb_hid_print_usage_path(usb_hid_report_path_t *path);
Index: uspace/lib/usbhid/include/usb/hid/hidtypes.h
===================================================================
--- uspace/lib/usbhid/include/usb/hid/hidtypes.h	(revision 14e1bcc46c8957d6c1c7726e8185e23d95ae25be)
+++ uspace/lib/usbhid/include/usb/hid/hidtypes.h	(revision f3b39b431bddc818b72efc239b05c1caad7fd5c4)
@@ -72,9 +72,15 @@
 
 /**
- * Report type
+ * Enum of report types
  */
 typedef enum {
+	/** Input report. Data are sent from device to system */
 	USB_HID_REPORT_TYPE_INPUT = 1,
+
+	/** Output report. Data are sent from system to device */
 	USB_HID_REPORT_TYPE_OUTPUT = 2,
+
+	/** Feature report. Describes device configuration information that
+	 * can be sent to the device */
 	USB_HID_REPORT_TYPE_FEATURE = 3
 } usb_hid_report_type_t;
Index: uspace/lib/usbhid/src/hiddescriptor.c
===================================================================
--- uspace/lib/usbhid/src/hiddescriptor.c	(revision 14e1bcc46c8957d6c1c7726e8185e23d95ae25be)
+++ uspace/lib/usbhid/src/hiddescriptor.c	(revision f3b39b431bddc818b72efc239b05c1caad7fd5c4)
@@ -41,8 +41,25 @@
 #include <assert.h>
 
-
+/*---------------------------------------------------------------------------*/
+/*
+ * Constants defining current parsing mode for correct parsing of the set of
+ * local tags (usage) enclosed in delimter tags.
+ */
+/**
+ * Second delimiter tag was read. The set of local items (usage) ended.
+ */
 #define OUTSIDE_DELIMITER_SET	0
+
+/**
+ * First delimiter tag was read. The set of local items (usage) started.
+ */
 #define START_DELIMITER_SET	1
+
+/**
+ * Parser is in the set of local items.
+ */
 #define INSIDE_DELIMITER_SET	2
+
+/*---------------------------------------------------------------------------*/
 	
 /** The new report item flag. Used to determine when the item is completly
@@ -61,16 +78,30 @@
 #define USB_HID_UNKNOWN_TAG		-99
 
-usb_hid_report_path_t *usb_hid_report_path_try_insert(usb_hid_report_t *report, usb_hid_report_path_t *cmp_path)
-{
-	/* find or append current collection path to the list */
-	//link_t *path_it = report->collection_paths.next;
+/*---------------------------------------------------------------------------*/
+/**
+ * Checks if given collection path is already present in report structure and
+ * inserts it if not.
+ *
+ * @param report Report structure 
+ * @param cmp_path The collection path 
+ * @return Pointer to the result collection path in report structure.
+ * @retval NULL If some error occurs
+ */
+usb_hid_report_path_t *usb_hid_report_path_try_insert(
+		usb_hid_report_t *report, usb_hid_report_path_t *cmp_path) {
+	
 	link_t *path_it = report->collection_paths.prev->next;
 	usb_hid_report_path_t *path = NULL;
 	
+	if((report == NULL) || (cmp_path == NULL)) {
+		return NULL;
+	}
 	
 	while(path_it != &report->collection_paths) {
-		path = list_get_instance(path_it, usb_hid_report_path_t, link);
-		
-		if(usb_hid_report_compare_usage_path(path, cmp_path, USB_HID_PATH_COMPARE_STRICT) == EOK){
+		path = list_get_instance(path_it, usb_hid_report_path_t,
+				link);
+		
+		if(usb_hid_report_compare_usage_path(path, cmp_path,
+					USB_HID_PATH_COMPARE_STRICT) == EOK){
 			break;
 		}			
@@ -78,5 +109,8 @@
 	}
 	if(path_it == &report->collection_paths) {
-		path = usb_hid_report_path_clone(cmp_path);			
+		path = usb_hid_report_path_clone(cmp_path);
+		if(path == NULL) {
+			return NULL;
+		}
 		list_append(&path->link, &report->collection_paths);					
 		report->collection_paths_count++;
@@ -85,8 +119,10 @@
 	}
 	else {
-		return list_get_instance(path_it, usb_hid_report_path_t, link);
-	}
-}
-
+		return list_get_instance(path_it, usb_hid_report_path_t,
+				link); 
+	}
+}
+
+/*---------------------------------------------------------------------------*/
 /**
  * Initialize the report descriptor parser structure
@@ -94,4 +130,6 @@
  * @param parser Report descriptor parser structure
  * @return Error code
+ * @retval EINVAL If no report structure was given
+ * @retval EOK If report structure was successfully initialized
  */
 int usb_hid_report_init(usb_hid_report_t *report)
@@ -109,11 +147,21 @@
 }
 
-
-/*
- *
- *
- */
-int usb_hid_report_append_fields(usb_hid_report_t *report, usb_hid_report_item_t *report_item)
-{
+/*---------------------------------------------------------------------------*/
+
+/**
+ *
+ *
+ * @param report Report structure in which the new report items should be
+ * 		 stored
+ * @param report_item Current report descriptor's parsing state table 
+ * @return Error code
+ * @retval EOK If all fields were successfully append to report
+ * @retval EINVAL If invalid parameters (NULL) was given
+ * @retval ENOMEM If there is no memmory to store new report description
+ *
+ */
+int usb_hid_report_append_fields(usb_hid_report_t *report,
+		usb_hid_report_item_t *report_item) {
+
 	usb_hid_report_field_t *field;
 	int i;
@@ -121,7 +169,13 @@
 	uint32_t *usages;
 	int usages_used=0;
+
+	if((report == NULL) || (report_item == NULL)) {
+		return EINVAL;
+	}
+
 	if(report_item->usages_count > 0){
 		usages = malloc(sizeof(int32_t) * report_item->usages_count);
-		memcpy(usages, report_item->usages, sizeof(int32_t) * report_item->usages_count);
+		memcpy(usages, report_item->usages, sizeof(int32_t) *
+				report_item->usages_count); 
 	}
 	else {
@@ -144,6 +198,6 @@
 		if(USB_HID_ITEM_FLAG_VARIABLE(report_item->item_flags) == 0){
 			/* 
-			 	Store usage array. The Correct Usage Page and Usage is depending 
-			 	on data in report and will be filled later
+			Store usage array. The Correct Usage Page and Usage is
+			depending on data in report and will be filled later
 			*/
 			field->usage = 0;
@@ -162,10 +216,12 @@
 			}
 			else {
-				usage = report_item->usages[report_item->usages_count - 1];
+				usage =	report_item->usages[
+					report_item->usages_count- 1]; 
 			}
 
 			if(USB_HID_IS_EXTENDED_USAGE(usage)){
 				field->usage = USB_HID_EXTENDED_USAGE(usage);
-				field->usage_page = USB_HID_EXTENDED_USAGE_PAGE(usage);
+				field->usage_page = 
+					USB_HID_EXTENDED_USAGE_PAGE(usage);
 			}
 			else {
@@ -176,13 +232,19 @@
 		}
 		
-		usb_hid_report_set_last_item(path, USB_HID_TAG_CLASS_GLOBAL, field->usage_page);
-		usb_hid_report_set_last_item(path, USB_HID_TAG_CLASS_LOCAL, field->usage);
-
-		field->collection_path = usb_hid_report_path_try_insert(report, path);
+		usb_hid_report_set_last_item(path, USB_HID_TAG_CLASS_GLOBAL,
+				field->usage_page);
+		usb_hid_report_set_last_item(path, USB_HID_TAG_CLASS_LOCAL,
+				field->usage);
+
+		field->collection_path =
+			usb_hid_report_path_try_insert(report, path);
 
 		field->size = report_item->size;
 		
-		size_t offset_byte = (report_item->offset + (i * report_item->size)) / 8;
-		size_t offset_bit = 8 - ((report_item->offset + (i * report_item->size)) % 8) - report_item->size;
+		size_t offset_byte = (report_item->offset + (i *
+			report_item->size)) / 8; 
+
+		size_t offset_bit = 8 - ((report_item->offset + (i *
+			report_item->size)) % 8) - report_item->size;
 
 		field->offset = 8 * offset_byte + offset_bit;
@@ -195,8 +257,16 @@
 		/* find the right report list*/
 		usb_hid_report_description_t *report_des;
-		report_des = usb_hid_report_find_description(report, report_item->id, report_item->type);
+		report_des = usb_hid_report_find_description(report,
+			report_item->id, report_item->type);
+		
 		if(report_des == NULL){
-			report_des = malloc(sizeof(usb_hid_report_description_t));
-			memset(report_des, 0, sizeof(usb_hid_report_description_t));
+			report_des = malloc(
+				sizeof(usb_hid_report_description_t));
+			if(report_des == NULL) {
+				return ENOMEM;
+			}
+
+			memset(report_des, 0,
+				sizeof(usb_hid_report_description_t));
 
 			report_des->type = report_item->type;
@@ -225,14 +295,28 @@
 	return EOK;
 }
-
-usb_hid_report_description_t * usb_hid_report_find_description(const usb_hid_report_t *report, uint8_t report_id, usb_hid_report_type_t type)
-{
+/*---------------------------------------------------------------------------*/
+/**
+ * Finds description of report with given report_id and of given type in
+ * opaque report structure.
+ *
+ * @param report Opaque structure containing the parsed report descriptor
+ * @param report_id ReportId of report we are searching
+ * @param type Type of report we are searching
+ * @return Pointer to the particular report description
+ * @retval NULL If no description is founded
+ */
+usb_hid_report_description_t * usb_hid_report_find_description(
+		const usb_hid_report_t *report, uint8_t report_id,
+		usb_hid_report_type_t type) {
+
 	link_t *report_it = report->reports.next;
 	usb_hid_report_description_t *report_des = NULL;
 	
 	while(report_it != &report->reports) {
-		report_des = list_get_instance(report_it, usb_hid_report_description_t, link);
-
-		if((report_des->report_id == report_id) && (report_des->type == type)){
+		report_des = list_get_instance(report_it,
+				usb_hid_report_description_t, link);
+
+		if((report_des->report_id == report_id) && 
+		   (report_des->type == type)) { 
 			return report_des;
 		}
@@ -243,4 +327,5 @@
 	return NULL;
 }
+/*---------------------------------------------------------------------------*/
 
 /** Parse HID report descriptor.
@@ -249,4 +334,7 @@
  * @param data Data describing the report.
  * @return Error code.
+ * @retval ENOMEM If no more memmory is available
+ * @retval EINVAL If invalid data are founded
+ * @retval EOK If report descriptor is successfully parsed
  */
 int usb_hid_parse_report_descriptor(usb_hid_report_t *report, 
@@ -299,88 +387,114 @@
 			
 			ret = usb_hid_report_parse_tag(tag,class,data+i+1,
-			                               item_size,report_item, usage_path);
+				item_size,report_item, usage_path);
+
 			switch(ret){
-				case USB_HID_NEW_REPORT_ITEM:
-					// store report item to report and create the new one
-					// store current collection path
-					report_item->usage_path = usage_path;
+			case USB_HID_NEW_REPORT_ITEM:
+				/* store report item to report and create the
+				 * new one store current collection path
+				 */
+				report_item->usage_path = usage_path;
 					
-					usb_hid_report_path_set_report_id(report_item->usage_path, report_item->id);	
-					if(report_item->id != 0){
-						report->use_report_ids = 1;
-					}
+				usb_hid_report_path_set_report_id(
+				     report_item->usage_path, report_item->id);
+				
+				if(report_item->id != 0){
+					report->use_report_ids = 1;
+				}
 					
-					switch(tag) {
-						case USB_HID_REPORT_TAG_INPUT:
-							report_item->type = USB_HID_REPORT_TYPE_INPUT;
-							report_item->offset = offset_input;
-							offset_input += report_item->count * report_item->size;
-							break;
-						case USB_HID_REPORT_TAG_OUTPUT:
-							report_item->type = USB_HID_REPORT_TYPE_OUTPUT;
-							report_item->offset = offset_output;
-							offset_output += report_item->count * report_item->size;
-
-							break;
-						case USB_HID_REPORT_TAG_FEATURE:
-							report_item->type = USB_HID_REPORT_TYPE_FEATURE;
-							report_item->offset = offset_feature;
-							offset_feature += report_item->count * report_item->size;
-							break;
-						default:
-						    usb_log_debug("\tjump over - tag %X\n", tag);
-						    break;
-					}
+				switch(tag) {
+				case USB_HID_REPORT_TAG_INPUT:
+					report_item->type = 
+					    USB_HID_REPORT_TYPE_INPUT;
+
+					report_item->offset = offset_input;
+					offset_input += report_item->count * 
+					    report_item->size;
+					break;
+	
+				case USB_HID_REPORT_TAG_OUTPUT:
+					report_item->type = 
+					    USB_HID_REPORT_TYPE_OUTPUT;
 					
-					/* 
-					 * append new fields to the report
-					 * structure 					 
-					 */
-					usb_hid_report_append_fields(report, report_item);
-
-					/* reset local items */
-					usb_hid_report_reset_local_items (report_item);
-
+					report_item->offset = offset_output;
+					offset_output += report_item->count * 
+					    report_item->size;
 					break;
-
-				case USB_HID_RESET_OFFSET:
-					offset_input = 0;
-					offset_output = 0;
-					offset_feature = 0;
-					usb_hid_report_path_set_report_id (usage_path, report_item->id);
+	
+				case USB_HID_REPORT_TAG_FEATURE:
+					report_item->type = 
+					    USB_HID_REPORT_TYPE_FEATURE;
+
+					report_item->offset = offset_feature;
+					offset_feature += report_item->count * 
+						report_item->size;
 					break;
-
-				case USB_HID_REPORT_TAG_PUSH:
-					// push current state to stack
-					new_report_item = usb_hid_report_item_clone(report_item);
-					usb_hid_report_path_t *tmp_path = usb_hid_report_path_clone(usage_path);
-					new_report_item->usage_path = tmp_path; 
-
-					list_prepend (&new_report_item->link, &stack);
-					break;
-				case USB_HID_REPORT_TAG_POP:
-					// restore current state from stack
-					if(list_empty (&stack)) {
-						return EINVAL;
-					}
-					free(report_item);
+	
+				default:
+					usb_log_debug2(
+					    "\tjump over - tag %X\n", tag);
+				    	break;
+				}
+					
+				/* 
+				 * append new fields to the report structure 					 
+				 */
+				usb_hid_report_append_fields(report, 
+				    report_item);
+
+				/* reset local items */
+				usb_hid_report_reset_local_items (report_item);
+				break;
+
+			case USB_HID_RESET_OFFSET:
+				offset_input = 0;
+				offset_output = 0;
+				offset_feature = 0;
+				usb_hid_report_path_set_report_id (usage_path, 
+				    report_item->id);
+				break;
+
+			case USB_HID_REPORT_TAG_PUSH:
+				// push current state to stack
+				new_report_item = usb_hid_report_item_clone(
+				    report_item);
+				
+				usb_hid_report_path_t *tmp_path = 
+				    usb_hid_report_path_clone(usage_path);
+
+				new_report_item->usage_path = tmp_path; 
+
+				list_prepend (&new_report_item->link, &stack);
+				break;
+			case USB_HID_REPORT_TAG_POP:
+				// restore current state from stack
+				if(list_empty (&stack)) {
+					return EINVAL;
+				}
+				free(report_item);
 						
-					report_item = list_get_instance(stack.next, usb_hid_report_item_t, link);
+				report_item = list_get_instance(stack.next, 
+				    usb_hid_report_item_t, link);
 					
-					usb_hid_report_usage_path_t *tmp_usage_path;
-					tmp_usage_path = list_get_instance(report_item->usage_path->link.prev, usb_hid_report_usage_path_t, link);
+				usb_hid_report_usage_path_t *tmp_usage_path;
+				tmp_usage_path = list_get_instance(
+				    report_item->usage_path->link.prev, 
+				    usb_hid_report_usage_path_t, link);
 					
-					usb_hid_report_set_last_item(usage_path, USB_HID_TAG_CLASS_GLOBAL, tmp_usage_path->usage_page);
-					usb_hid_report_set_last_item(usage_path, USB_HID_TAG_CLASS_LOCAL, tmp_usage_path->usage);
-
-					usb_hid_report_path_free(report_item->usage_path);
-					list_initialize(&report_item->usage_path->link);
-					list_remove (stack.next);
+				usb_hid_report_set_last_item(usage_path, 
+				    USB_HID_TAG_CLASS_GLOBAL, tmp_usage_path->usage_page);
+				
+				usb_hid_report_set_last_item(usage_path, 
+				    USB_HID_TAG_CLASS_LOCAL, tmp_usage_path->usage);
+
+				usb_hid_report_path_free(report_item->usage_path);
+				list_initialize(&report_item->usage_path->link);
+				list_remove (stack.next);
 					
-					break;
+				break;
 					
-				default:
-					// nothing special to do					
-					break;
+			default:
+				// nothing special to do					
+				break;
 			}
 
@@ -399,4 +513,5 @@
 }
 
+/*---------------------------------------------------------------------------*/
 
 /**
@@ -409,30 +524,35 @@
  * @return Code of action to be done next
  */
-int usb_hid_report_parse_tag(uint8_t tag, uint8_t class, const uint8_t *data, size_t item_size,
-                             usb_hid_report_item_t *report_item, usb_hid_report_path_t *usage_path)
-{	
+int usb_hid_report_parse_tag(uint8_t tag, uint8_t class, const uint8_t *data,
+	size_t item_size, usb_hid_report_item_t *report_item,
+	usb_hid_report_path_t *usage_path) {	
+	
 	int ret;
 	
 	switch(class){
-		case USB_HID_TAG_CLASS_MAIN:
-
-			if((ret=usb_hid_report_parse_main_tag(tag,data,item_size,report_item, usage_path)) == EOK) {
-				return USB_HID_NEW_REPORT_ITEM;
-			}
-			else {
-				/*TODO process the error */
-				return ret;
-			   }
-			break;
-
-		case USB_HID_TAG_CLASS_GLOBAL:	
-			return usb_hid_report_parse_global_tag(tag,data,item_size,report_item, usage_path);
-			break;
-
-		case USB_HID_TAG_CLASS_LOCAL:			
-			return usb_hid_report_parse_local_tag(tag,data,item_size,report_item, usage_path);
-			break;
-		default:
-			return USB_HID_NO_ACTION;
+	case USB_HID_TAG_CLASS_MAIN:
+
+		if((ret=usb_hid_report_parse_main_tag(tag, data, item_size,
+			report_item, usage_path)) == EOK) {
+
+			return USB_HID_NEW_REPORT_ITEM;
+		}
+		else {
+			return ret;
+		}
+		break;
+
+	case USB_HID_TAG_CLASS_GLOBAL:	
+		return usb_hid_report_parse_global_tag(tag, data, item_size,
+			report_item, usage_path);
+		break;
+
+	case USB_HID_TAG_CLASS_LOCAL:			
+		return usb_hid_report_parse_local_tag(tag, data, item_size,
+			report_item, usage_path);
+		break;
+	
+	default:
+		return USB_HID_NO_ACTION;
 	}
 }
@@ -448,6 +568,7 @@
  */
 
-int usb_hid_report_parse_main_tag(uint8_t tag, const uint8_t *data, size_t item_size,
-                             usb_hid_report_item_t *report_item, usb_hid_report_path_t *usage_path)
+int usb_hid_report_parse_main_tag(uint8_t tag, const uint8_t *data, 
+	size_t item_size, usb_hid_report_item_t *report_item,
+	usb_hid_report_path_t *usage_path)
 {
 	usb_hid_report_usage_path_t *path_item;
@@ -455,38 +576,46 @@
 	switch(tag)
 	{
-		case USB_HID_REPORT_TAG_INPUT:
-		case USB_HID_REPORT_TAG_OUTPUT:
-		case USB_HID_REPORT_TAG_FEATURE:
-			report_item->item_flags = *data;			
-			return EOK;			
-			break;
+	case USB_HID_REPORT_TAG_INPUT:
+	case USB_HID_REPORT_TAG_OUTPUT:
+	case USB_HID_REPORT_TAG_FEATURE:
+		report_item->item_flags = *data;			
+		return EOK;			
+		break;
 			
-		case USB_HID_REPORT_TAG_COLLECTION:
-
-			// store collection atributes
-			path_item = list_get_instance(usage_path->head.prev, usb_hid_report_usage_path_t, link);
-			path_item->flags = *data;	
+	case USB_HID_REPORT_TAG_COLLECTION:
+
+		/* store collection atributes */
+		path_item = list_get_instance(usage_path->head.prev, 
+			usb_hid_report_usage_path_t, link);
+		path_item->flags = *data;	
 			
-			// set last item
-			usb_hid_report_set_last_item(usage_path, 
-			                             USB_HID_TAG_CLASS_GLOBAL, 
-			                             USB_HID_EXTENDED_USAGE_PAGE(report_item->usages[report_item->usages_count-1]));
-			usb_hid_report_set_last_item(usage_path, 
-			                             USB_HID_TAG_CLASS_LOCAL, 
-			                             USB_HID_EXTENDED_USAGE(report_item->usages[report_item->usages_count-1]));
+		/* set last item */
+		usb_hid_report_set_last_item(usage_path, 
+			USB_HID_TAG_CLASS_GLOBAL, 
+			USB_HID_EXTENDED_USAGE_PAGE(report_item->usages[
+				report_item->usages_count-1]));
+
+		usb_hid_report_set_last_item(usage_path, 
+			USB_HID_TAG_CLASS_LOCAL, 
+			USB_HID_EXTENDED_USAGE(report_item->usages[
+				report_item->usages_count-1]));
 			
-			// append the new one which will be set by common
-			// usage/usage page
-			usb_hid_report_path_append_item(usage_path, report_item->usage_page, report_item->usages[report_item->usages_count-1]);	
-			usb_hid_report_reset_local_items (report_item);
-			return USB_HID_NO_ACTION;
-			break;
+		/* append the new one which will be set by common usage/usage
+		 * page */
+		usb_hid_report_path_append_item(usage_path, 
+			report_item->usage_page, 
+			report_item->usages[report_item->usages_count-1]);
+
+		usb_hid_report_reset_local_items (report_item);
+		return USB_HID_NO_ACTION;
+		break;
 			
-		case USB_HID_REPORT_TAG_END_COLLECTION:
-			usb_hid_report_remove_last_item(usage_path);
-			return USB_HID_NO_ACTION;
-			break;
-		default:
-			return USB_HID_NO_ACTION;
+	case USB_HID_REPORT_TAG_END_COLLECTION:
+		usb_hid_report_remove_last_item(usage_path);
+		return USB_HID_NO_ACTION;
+		break;
+
+	default:
+		return USB_HID_NO_ACTION;
 	}
 
@@ -503,53 +632,76 @@
  * @return Error code
  */
-int usb_hid_report_parse_global_tag(uint8_t tag, const uint8_t *data, size_t item_size,
-                             usb_hid_report_item_t *report_item, usb_hid_report_path_t *usage_path)
-{
-	// TODO take care about the bit length of data
+int usb_hid_report_parse_global_tag(uint8_t tag, const uint8_t *data, 
+	size_t item_size, usb_hid_report_item_t *report_item, 
+	usb_hid_report_path_t *usage_path) { 
+	
 	switch(tag)
 	{
-		case USB_HID_REPORT_TAG_USAGE_PAGE:
-			report_item->usage_page = usb_hid_report_tag_data_uint32(data, item_size);
-			break;
-		case USB_HID_REPORT_TAG_LOGICAL_MINIMUM:
-			report_item->logical_minimum = USB_HID_UINT32_TO_INT32(usb_hid_report_tag_data_uint32(data,item_size), item_size * 8);
-			break;
-		case USB_HID_REPORT_TAG_LOGICAL_MAXIMUM:
-			report_item->logical_maximum = USB_HID_UINT32_TO_INT32(usb_hid_report_tag_data_uint32(data,item_size), item_size * 8);
-			break;
-		case USB_HID_REPORT_TAG_PHYSICAL_MINIMUM:
-			report_item->physical_minimum = USB_HID_UINT32_TO_INT32(usb_hid_report_tag_data_uint32(data,item_size), item_size * 8);
-			break;			
-		case USB_HID_REPORT_TAG_PHYSICAL_MAXIMUM:
-			report_item->physical_maximum = USB_HID_UINT32_TO_INT32(usb_hid_report_tag_data_uint32(data,item_size), item_size * 8);
-
-			break;
-		case USB_HID_REPORT_TAG_UNIT_EXPONENT:
-			report_item->unit_exponent = usb_hid_report_tag_data_uint32(data,item_size);
-			break;
-		case USB_HID_REPORT_TAG_UNIT:
-			report_item->unit = usb_hid_report_tag_data_uint32(data,item_size);
-			break;
-		case USB_HID_REPORT_TAG_REPORT_SIZE:
-			report_item->size = usb_hid_report_tag_data_uint32(data,item_size);
-			break;
-		case USB_HID_REPORT_TAG_REPORT_COUNT:
-			report_item->count = usb_hid_report_tag_data_uint32(data,item_size);
-			break;
-		case USB_HID_REPORT_TAG_REPORT_ID:
-			report_item->id = usb_hid_report_tag_data_uint32(data,item_size);
-			return USB_HID_RESET_OFFSET;
-			break;
-		case USB_HID_REPORT_TAG_PUSH:
-		case USB_HID_REPORT_TAG_POP:
-			/* 
-			 * stack operations are done in top level parsing
-			 * function
-			 */
-			return tag;
-			break;
+	case USB_HID_REPORT_TAG_USAGE_PAGE:
+		report_item->usage_page = 
+			usb_hid_report_tag_data_uint32(data, item_size);
+		break;
+
+	case USB_HID_REPORT_TAG_LOGICAL_MINIMUM:
+		report_item->logical_minimum = USB_HID_UINT32_TO_INT32(
+			usb_hid_report_tag_data_uint32(data,item_size),
+		       	item_size * 8);
+		break;
+
+	case USB_HID_REPORT_TAG_LOGICAL_MAXIMUM:
+		report_item->logical_maximum = USB_HID_UINT32_TO_INT32(
+			usb_hid_report_tag_data_uint32(data,item_size), 
+			item_size * 8);
+		break;
+
+	case USB_HID_REPORT_TAG_PHYSICAL_MINIMUM:
+		report_item->physical_minimum = USB_HID_UINT32_TO_INT32(
+			usb_hid_report_tag_data_uint32(data,item_size), 
+			item_size * 8);
+		break;			
+
+	case USB_HID_REPORT_TAG_PHYSICAL_MAXIMUM:
+		report_item->physical_maximum = USB_HID_UINT32_TO_INT32(
+			usb_hid_report_tag_data_uint32(data,item_size), 
+			item_size * 8);
+		break;
+
+	case USB_HID_REPORT_TAG_UNIT_EXPONENT:
+		report_item->unit_exponent = usb_hid_report_tag_data_uint32(
+			data,item_size);
+		break;
+
+	case USB_HID_REPORT_TAG_UNIT:
+		report_item->unit = usb_hid_report_tag_data_uint32(
+			data,item_size);
+		break;
+
+	case USB_HID_REPORT_TAG_REPORT_SIZE:
+		report_item->size = usb_hid_report_tag_data_uint32(
+			data,item_size);
+		break;
+
+	case USB_HID_REPORT_TAG_REPORT_COUNT:
+		report_item->count = usb_hid_report_tag_data_uint32(
+			data,item_size);
+		break;
+
+	case USB_HID_REPORT_TAG_REPORT_ID:
+		report_item->id = usb_hid_report_tag_data_uint32(data, 
+			item_size);
+		return USB_HID_RESET_OFFSET;
+		break;
+	
+	case USB_HID_REPORT_TAG_PUSH:
+	case USB_HID_REPORT_TAG_POP:
+		/* 
+		 * stack operations are done in top level parsing
+		 * function
+		 */
+		return tag;
+		break;
 			
-		default:
-			return USB_HID_NO_ACTION;
+	default:
+		return USB_HID_NO_ACTION;
 	}
 
@@ -566,92 +718,135 @@
  * @return Error code
  */
-int usb_hid_report_parse_local_tag(uint8_t tag, const uint8_t *data, size_t item_size,
-                             usb_hid_report_item_t *report_item, usb_hid_report_path_t *usage_path)
+int usb_hid_report_parse_local_tag(uint8_t tag, const uint8_t *data, 
+	size_t item_size, usb_hid_report_item_t *report_item, 
+	usb_hid_report_path_t *usage_path)
 {
 	int32_t extended_usage;
 	
 	switch(tag) {
-		case USB_HID_REPORT_TAG_USAGE:
-			switch(report_item->in_delimiter) {
-				case INSIDE_DELIMITER_SET:
-					// nothing to do
-					break;
-				case START_DELIMITER_SET:
-					report_item->in_delimiter = INSIDE_DELIMITER_SET;
-				case OUTSIDE_DELIMITER_SET:
-					extended_usage = ((report_item->usage_page) << 16);
-					extended_usage += usb_hid_report_tag_data_uint32(data,item_size);
-					report_item->usages[report_item->usages_count] = extended_usage;
-					report_item->usages_count++;
-					break;
+	case USB_HID_REPORT_TAG_USAGE:
+		switch(report_item->in_delimiter) {
+		case INSIDE_DELIMITER_SET:
+			/* nothing to do
+			 * we catch only the first one
+			 */
+			break;
+	
+		case START_DELIMITER_SET:
+			report_item->in_delimiter = INSIDE_DELIMITER_SET;
+		case OUTSIDE_DELIMITER_SET:
+			extended_usage = ((report_item->usage_page) << 16);
+			extended_usage += usb_hid_report_tag_data_uint32(
+				data,item_size);
+
+			report_item->usages[report_item->usages_count] = 
+				extended_usage;
+
+			report_item->usages_count++;
+			break;
+		}
+		break;
+		
+	case USB_HID_REPORT_TAG_USAGE_MINIMUM:			
+		if (item_size == 3) {
+			// usage extended usages
+			report_item->extended_usage_page = 
+			    USB_HID_EXTENDED_USAGE_PAGE(
+			    usb_hid_report_tag_data_uint32(data,item_size));
+			   
+
+			report_item->usage_minimum = 
+			    USB_HID_EXTENDED_USAGE(
+			    usb_hid_report_tag_data_uint32(data,item_size));
+		}
+		else {
+			report_item->usage_minimum = 
+			    usb_hid_report_tag_data_uint32(data,item_size);
+		}
+		break;
+	
+	case USB_HID_REPORT_TAG_USAGE_MAXIMUM:
+		if (item_size == 3) {
+			if(report_item->extended_usage_page != 
+			    USB_HID_EXTENDED_USAGE_PAGE(	
+			    usb_hid_report_tag_data_uint32(data,item_size))) {
+				
+				return EINVAL;
 			}
-			break;
-		case USB_HID_REPORT_TAG_USAGE_MINIMUM:			
-			if (item_size == 3) {
-				// usage extended usages
-				report_item->extended_usage_page = (usb_hid_report_tag_data_uint32(data,item_size) & 0xFF00) >> 16; 
-				report_item->usage_minimum = usb_hid_report_tag_data_uint32(data,item_size) & 0xFF;
+				
+			// usage extended usages
+			report_item->extended_usage_page = 
+				USB_HID_EXTENDED_USAGE_PAGE(
+				usb_hid_report_tag_data_uint32(data,item_size));
+
+			report_item->usage_maximum = 
+				USB_HID_EXTENDED_USAGE(
+				usb_hid_report_tag_data_uint32(data,item_size));
+		}
+		else {
+			report_item->usage_maximum = 
+				usb_hid_report_tag_data_uint32(data,item_size);
+		}
+
+		// vlozit zaznamy do pole usages
+		int32_t i;
+		for(i = report_item->usage_minimum; 
+		    i <= report_item->usage_maximum; i++) {
+
+			if(report_item->extended_usage_page) {
+			    report_item->usages[report_item->usages_count++] = 
+				(report_item->extended_usage_page << 16) + i;
 			}
-			else {
-				report_item->usage_minimum = usb_hid_report_tag_data_uint32(data,item_size);
+			else {			
+			    report_item->usages[report_item->usages_count++] = 
+				(report_item->usage_page << 16) + i;
 			}
-			break;
-		case USB_HID_REPORT_TAG_USAGE_MAXIMUM:
-			if (item_size == 3) {
-
-				if(report_item->extended_usage_page != ((usb_hid_report_tag_data_uint32(data,item_size) & 0xFF00) >> 16)) {
-					return EINVAL;
-				}
-				
-				// usage extended usages
-				report_item->extended_usage_page = (usb_hid_report_tag_data_uint32(data,item_size) & 0xFF00) >> 16; 
-				report_item->usage_maximum = usb_hid_report_tag_data_uint32(data,item_size) & 0xFF;
-			}
-			else {
-				report_item->usage_maximum = usb_hid_report_tag_data_uint32(data,item_size);
-			}
-
-			// vlozit zaznamy do pole usages
-			int32_t i;
-			for(i=report_item->usage_minimum; i<=report_item->usage_maximum; i++) {
-				if(report_item->extended_usage_page) {
-					report_item->usages[report_item->usages_count++] = (report_item->extended_usage_page << 16) + i;
-				}
-				else {
-					
-					report_item->usages[report_item->usages_count++] = (report_item->usage_page << 16) + i;
-				}
-			}
-			report_item->extended_usage_page = 0;
+		}
+		report_item->extended_usage_page = 0;
 			
-			break;
-		case USB_HID_REPORT_TAG_DESIGNATOR_INDEX:
-			report_item->designator_index = usb_hid_report_tag_data_uint32(data,item_size);
-			break;
-		case USB_HID_REPORT_TAG_DESIGNATOR_MINIMUM:
-			report_item->designator_minimum = usb_hid_report_tag_data_uint32(data,item_size);
-			break;
-		case USB_HID_REPORT_TAG_DESIGNATOR_MAXIMUM:
-			report_item->designator_maximum = usb_hid_report_tag_data_uint32(data,item_size);
-			break;
-		case USB_HID_REPORT_TAG_STRING_INDEX:
-			report_item->string_index = usb_hid_report_tag_data_uint32(data,item_size);
-			break;
-		case USB_HID_REPORT_TAG_STRING_MINIMUM:
-			report_item->string_minimum = usb_hid_report_tag_data_uint32(data,item_size);
-			break;
-		case USB_HID_REPORT_TAG_STRING_MAXIMUM:
-			report_item->string_maximum = usb_hid_report_tag_data_uint32(data,item_size);
-			break;			
-		case USB_HID_REPORT_TAG_DELIMITER:
-			report_item->in_delimiter = usb_hid_report_tag_data_uint32(data,item_size);
-			break;
-
-		default:
-			return USB_HID_NO_ACTION;
+		break;
+		
+	case USB_HID_REPORT_TAG_DESIGNATOR_INDEX:
+		report_item->designator_index = 
+			usb_hid_report_tag_data_uint32(data,item_size);
+		break;
+	
+	case USB_HID_REPORT_TAG_DESIGNATOR_MINIMUM:
+		report_item->designator_minimum = 
+			usb_hid_report_tag_data_uint32(data,item_size);
+		break;
+
+	case USB_HID_REPORT_TAG_DESIGNATOR_MAXIMUM:
+		report_item->designator_maximum = 
+			usb_hid_report_tag_data_uint32(data,item_size);
+		break;
+
+	case USB_HID_REPORT_TAG_STRING_INDEX:
+		report_item->string_index = 
+			usb_hid_report_tag_data_uint32(data,item_size);
+		break;
+
+	case USB_HID_REPORT_TAG_STRING_MINIMUM:
+		report_item->string_minimum = 
+			usb_hid_report_tag_data_uint32(data,item_size);
+		break;
+
+	case USB_HID_REPORT_TAG_STRING_MAXIMUM:
+		report_item->string_maximum = 
+			usb_hid_report_tag_data_uint32(data,item_size);
+		break;			
+
+	case USB_HID_REPORT_TAG_DELIMITER:
+		report_item->in_delimiter = 
+			usb_hid_report_tag_data_uint32(data,item_size);
+		break;
+
+	default:
+		return USB_HID_NO_ACTION;
 	}
 
 	return EOK;
 }
+/*---------------------------------------------------------------------------*/
 
 /**
@@ -674,4 +869,5 @@
 	return result;
 }
+/*---------------------------------------------------------------------------*/
 
 /**
@@ -694,15 +890,23 @@
 	for(item = head->next; item != head; item = item->next) {
                 
-		report_item = list_get_instance(item, usb_hid_report_field_t, link);
+		report_item = list_get_instance(item, usb_hid_report_field_t, 
+				link);
 
 		usb_log_debug("\t\tOFFSET: %X\n", report_item->offset);
-		usb_log_debug("\t\tSIZE: %zu\n", report_item->size);				
-		usb_log_debug("\t\tLOGMIN: %d\n", report_item->logical_minimum);
-		usb_log_debug("\t\tLOGMAX: %d\n", report_item->logical_maximum);		
-		usb_log_debug("\t\tPHYMIN: %d\n", report_item->physical_minimum);		
-		usb_log_debug("\t\tPHYMAX: %d\n", report_item->physical_maximum);				
-		usb_log_debug("\t\ttUSAGEMIN: %X\n", report_item->usage_minimum);
-		usb_log_debug("\t\tUSAGEMAX: %X\n", report_item->usage_maximum);
-		usb_log_debug("\t\tUSAGES COUNT: %zu\n", report_item->usages_count);
+		usb_log_debug("\t\tSIZE: %zu\n", report_item->size);
+		usb_log_debug("\t\tLOGMIN: %d\n", 
+			report_item->logical_minimum);
+		usb_log_debug("\t\tLOGMAX: %d\n", 
+			report_item->logical_maximum);		
+		usb_log_debug("\t\tPHYMIN: %d\n", 
+			report_item->physical_minimum);		
+		usb_log_debug("\t\tPHYMAX: %d\n", 
+			report_item->physical_maximum);				
+		usb_log_debug("\t\ttUSAGEMIN: %X\n", 
+			report_item->usage_minimum);
+		usb_log_debug("\t\tUSAGEMAX: %X\n",
+			       report_item->usage_maximum);
+		usb_log_debug("\t\tUSAGES COUNT: %zu\n", 
+			report_item->usages_count);
 
 		usb_log_debug("\t\tVALUE: %X\n", report_item->value);
@@ -716,6 +920,7 @@
 	}
 
-
-}
+}
+/*---------------------------------------------------------------------------*/
+
 /**
  * Prints content of given report descriptor in human readable format.
@@ -734,5 +939,6 @@
 
 	while(report_it != &report->reports) {
-		report_des = list_get_instance(report_it, usb_hid_report_description_t, link);
+		report_des = list_get_instance(report_it, 
+			usb_hid_report_description_t, link);
 		usb_log_debug("Report ID: %d\n", report_des->report_id);
 		usb_log_debug("\tType: %d\n", report_des->type);
@@ -742,14 +948,8 @@
 		usb_hid_descriptor_print_list(&report_des->report_items);
 
-/*
-		link_t *path_it = report->collection_paths.next;
-		while(path_it != &report->collection_paths) {
-			usb_hid_print_usage_path (list_get_instance(path_it, usb_hid_report_path_t, link));
-			path_it = path_it->next;
-		}
-*/		
 		report_it = report_it->next;
 	}
 }
+/*---------------------------------------------------------------------------*/
 
 /**
@@ -776,5 +976,5 @@
 
 		while(!list_empty(&report_item->usage_path->link)) {
-			usb_hid_report_remove_last_item(report_item->usage_path);
+		    usb_hid_report_remove_last_item(report_item->usage_path);
 		}
 
@@ -788,4 +988,5 @@
 	
 }
+/*---------------------------------------------------------------------------*/
 
 /** Frees the HID report descriptor parser structure 
@@ -803,5 +1004,7 @@
 	usb_hid_report_path_t *path;
 	while(!list_empty(&report->collection_paths)) {
-		path = list_get_instance(report->collection_paths.next, usb_hid_report_path_t, link);
+		path = list_get_instance(report->collection_paths.next, 
+				usb_hid_report_path_t, link);
+
 		usb_hid_report_path_free(path);		
 	}
@@ -811,9 +1014,14 @@
 	usb_hid_report_field_t *field;
 	while(!list_empty(&report->reports)) {
-		report_des = list_get_instance(report->reports.next, usb_hid_report_description_t, link);
+		report_des = list_get_instance(report->reports.next, 
+				usb_hid_report_description_t, link);
+
 		list_remove(&report_des->link);
 		
 		while(!list_empty(&report_des->report_items)) {
-			field = list_get_instance(report_des->report_items.next, usb_hid_report_field_t, link);
+			field = list_get_instance(
+				report_des->report_items.next, 
+				usb_hid_report_field_t, link);
+
 			list_remove(&field->link);
 
@@ -826,4 +1034,5 @@
 	return;
 }
+/*---------------------------------------------------------------------------*/
 
 /**
Index: uspace/lib/usbhid/src/hidparser.c
===================================================================
--- uspace/lib/usbhid/src/hidparser.c	(revision 14e1bcc46c8957d6c1c7726e8185e23d95ae25be)
+++ uspace/lib/usbhid/src/hidparser.c	(revision f3b39b431bddc818b72efc239b05c1caad7fd5c4)
@@ -167,5 +167,6 @@
 	while(list_item != &(report_des->report_items)) {
 
-		item = list_get_instance(list_item, usb_hid_report_field_t, link);
+		item = list_get_instance(list_item, usb_hid_report_field_t, 
+				link);
 
 		if(USB_HID_ITEM_FLAG_CONSTANT(item->item_flags) == 0) {
@@ -174,13 +175,16 @@
 
 				// array
-				item->value = usb_hid_translate_data(item, data);
+				item->value = 
+					usb_hid_translate_data(item, data);
 		
 				item->usage = USB_HID_EXTENDED_USAGE(
-					item->usages[item->value - item->physical_minimum]);
+				    item->usages[item->value - item->physical_minimum]);
+
 				item->usage_page = USB_HID_EXTENDED_USAGE_PAGE(
-					item->usages[item->value - item->physical_minimum]);				
+				    item->usages[item->value - item->physical_minimum]);
 
 				usb_hid_report_set_last_item (item->collection_path, 
-					USB_HID_TAG_CLASS_GLOBAL, item->usage_page);
+				    USB_HID_TAG_CLASS_GLOBAL, item->usage_page);
+
 				usb_hid_report_set_last_item (item->collection_path, 
 				    USB_HID_TAG_CLASS_LOCAL, item->usage);
@@ -273,5 +277,6 @@
 	}
 
-	return (int)(((value - item->logical_minimum) / resolution) + item->physical_minimum);
+	return (int)(((value - item->logical_minimum) / resolution) + 
+		item->physical_minimum);
 	
 }
@@ -415,17 +420,26 @@
 				if(i == (offset/8)) {
 					tmp_value = value;
-					tmp_value = tmp_value & ((1 << (8-(offset%8)))-1);				
+					tmp_value = tmp_value & 
+						((1 << (8-(offset%8)))-1);
+
 					tmp_value = tmp_value << (offset%8);
 	
-					mask = ~(((1 << (8-(offset%8)))-1) << (offset%8));
-					buffer[i] = (buffer[i] & mask) | tmp_value;			
+					mask = ~(((1 << (8-(offset%8)))-1) << 
+							(offset%8));
+
+					buffer[i] = (buffer[i] & mask) | 
+						tmp_value;
 				}
 				else if (i == ((offset + length -1)/8)) {
 					
-					value = value >> (length - ((offset + length) % 8));
-					value = value & 
-						((1 << (length - ((offset + length) % 8))) - 1);
+					value = value >> (length - 
+						((offset + length) % 8));
+
+					value = value & ((1 << (length - 
+						((offset + length) % 8))) - 1);
 				
-					mask = (1 << (length - ((offset + length) % 8))) - 1;
+					mask = (1 << (length - 
+						((offset + length) % 8))) - 1;
+
 					buffer[i] = (buffer[i] & mask) | value;
 				}
@@ -529,6 +543,6 @@
 	usb_hid_report_type_t type)
 {
-	usb_hid_report_description_t *report_des = usb_hid_report_find_description(
-		report, path->report_id, type);
+	usb_hid_report_description_t *report_des = 
+		usb_hid_report_find_description(report, path->report_id, type);
 
 	link_t *field_it;
@@ -546,17 +560,22 @@
 
 	while(field_it != &report_des->report_items) {
-		field = list_get_instance(field_it, usb_hid_report_field_t, link);
+		field = list_get_instance(field_it, usb_hid_report_field_t, 
+			link);
 
 		if(USB_HID_ITEM_FLAG_CONSTANT(field->item_flags) == 0) {
-			usb_hid_report_path_append_item (field->collection_path, 
-				field->usage_page, field->usage);
-
-			if(usb_hid_report_compare_usage_path(field->collection_path, path, 
-				flags) == EOK){
-
-				usb_hid_report_remove_last_item(field->collection_path);
+			usb_hid_report_path_append_item (
+				field->collection_path, field->usage_page, 
+				field->usage);
+
+			if(usb_hid_report_compare_usage_path(
+				field->collection_path, path, flags) == EOK){
+
+				usb_hid_report_remove_last_item(
+					field->collection_path);
+
 				return field;
 			}
-			usb_hid_report_remove_last_item (field->collection_path);
+			usb_hid_report_remove_last_item (
+				field->collection_path);
 		}
 		field_it = field_it->next;
Index: uspace/lib/usbhid/src/hidpath.c
===================================================================
--- uspace/lib/usbhid/src/hidpath.c	(revision 14e1bcc46c8957d6c1c7726e8185e23d95ae25be)
+++ uspace/lib/usbhid/src/hidpath.c	(revision f3b39b431bddc818b72efc239b05c1caad7fd5c4)
@@ -225,128 +225,131 @@
 	
 	switch(flags){
-		/* path is somewhere in report_path */
-		case USB_HID_PATH_COMPARE_ANYWHERE:
-			if(path->depth != 1){
-				return 1;
-			}
-
-			report_link = report_path->head.next;
-			path_link = path->head.next;
-			path_item = list_get_instance(path_link, 
+	/* path is somewhere in report_path */
+	case USB_HID_PATH_COMPARE_ANYWHERE:
+		if(path->depth != 1){
+			return 1;
+		}
+
+		report_link = report_path->head.next;
+		path_link = path->head.next;
+		path_item = list_get_instance(path_link, 
+			usb_hid_report_usage_path_t, link);
+
+		while(report_link != &report_path->head) {
+			report_item = list_get_instance(report_link, 
 				usb_hid_report_usage_path_t, link);
-
-			while(report_link != &report_path->head) {
-				report_item = list_get_instance(report_link, 
-					usb_hid_report_usage_path_t, link);
 				
-				if(USB_HID_SAME_USAGE_PAGE(report_item->usage_page, 
-					path_item->usage_page)){
+			if(USB_HID_SAME_USAGE_PAGE(report_item->usage_page, 
+				path_item->usage_page)){
 					
-					if(only_page == 0){
-						if(USB_HID_SAME_USAGE(report_item->usage, 
-							path_item->usage)) {
+				if(only_page == 0){
+					if(USB_HID_SAME_USAGE(
+						report_item->usage,
+						path_item->usage)) {
 							
-							return EOK;
-						}
-					}
-					else {
 						return EOK;
 					}
 				}
-
+				else {
+					return EOK;
+				}
+			}
+
+			report_link = report_link->next;
+		}
+
+		return 1;
+		break;
+
+	/* the paths must be identical */
+	case USB_HID_PATH_COMPARE_STRICT:
+		if(report_path->depth != path->depth){
+			return 1;
+		}
+		
+	/* path is prefix of the report_path */
+	case USB_HID_PATH_COMPARE_BEGIN:
+	
+		report_link = report_path->head.next;
+		path_link = path->head.next;
+			
+		while((report_link != &report_path->head) && 
+		      (path_link != &path->head)) {
+					  
+			report_item = list_get_instance(report_link, 
+				usb_hid_report_usage_path_t, link);
+					  
+			path_item = list_get_instance(path_link,
+       				usb_hid_report_usage_path_t, link);
+
+			if(!USB_HID_SAME_USAGE_PAGE(report_item->usage_page, 
+				path_item->usage_page) || ((only_page == 0) && 
+			    !USB_HID_SAME_USAGE(report_item->usage, 
+				path_item->usage))) {
+			
+				return 1;
+			} 
+			else {
 				report_link = report_link->next;
+				path_link = path_link->next;			
 			}
-
-			return 1;
-			break;
-		/* the paths must be identical */
-		case USB_HID_PATH_COMPARE_STRICT:
-				if(report_path->depth != path->depth){
-					return 1;
-				}
-		
-		/* path is prefix of the report_path */
-		case USB_HID_PATH_COMPARE_BEGIN:
-	
-				report_link = report_path->head.next;
-				path_link = path->head.next;
-			
-				while((report_link != &report_path->head) && 
-				      (path_link != &path->head)) {
-						  
-					report_item = list_get_instance(report_link, 
-                    	usb_hid_report_usage_path_t, link);
-						  
-					path_item = list_get_instance(path_link, 
-                    	usb_hid_report_usage_path_t, link);		
-
-					if(!USB_HID_SAME_USAGE_PAGE(report_item->usage_page, 
-						path_item->usage_page) || ((only_page == 0) && 
-					    !USB_HID_SAME_USAGE(report_item->usage, 
-						path_item->usage))) {
-							
-						   return 1;
-					} else {
-						report_link = report_link->next;
-						path_link = path_link->next;			
-					}
 			
 				}
 
-				if((((flags & USB_HID_PATH_COMPARE_BEGIN) != 0) && 
-					(path_link == &path->head)) || 
-				   ((report_link == &report_path->head) && 
-					(path_link == &path->head))) {
-					
-					return EOK;
-				}
-				else {
+		if((((flags & USB_HID_PATH_COMPARE_BEGIN) != 0) && 
+			(path_link == &path->head)) || 
+		   ((report_link == &report_path->head) && 
+			(path_link == &path->head))) {
+				
+			return EOK;
+		}
+		else {
+			return 1;
+		}						
+		break;
+
+	/* path is suffix of report_path */
+	case USB_HID_PATH_COMPARE_END:
+
+		report_link = report_path->head.prev;
+		path_link = path->head.prev;
+
+		if(list_empty(&path->head)){
+			return EOK;
+		}
+			
+		while((report_link != &report_path->head) && 
+		      (path_link != &path->head)) {
+						  
+			report_item = list_get_instance(report_link, 
+				usb_hid_report_usage_path_t, link);
+
+			path_item = list_get_instance(path_link, 
+				usb_hid_report_usage_path_t, link);		
+						  
+			if(!USB_HID_SAME_USAGE_PAGE(report_item->usage_page, 
+				path_item->usage_page) || ((only_page == 0) && 
+			    !USB_HID_SAME_USAGE(report_item->usage, 
+				path_item->usage))) {
+						
 					return 1;
-				}						
-			break;
-
-		/* path is suffix of report_path */
-		case USB_HID_PATH_COMPARE_END:
-
-				report_link = report_path->head.prev;
-				path_link = path->head.prev;
-
-				if(list_empty(&path->head)){
-					return EOK;
-				}
+			} else {
+				report_link = report_link->prev;
+				path_link = path_link->prev;			
+			}
+
+		}
+
+		if(path_link == &path->head) {
+			return EOK;
+		}
+		else {
+			return 1;
+		}						
 			
-				while((report_link != &report_path->head) && 
-				      (path_link != &path->head)) {
-						  
-					report_item = list_get_instance(report_link, 
-						usb_hid_report_usage_path_t, link);
-
-					path_item = list_get_instance(path_link, 
-						usb_hid_report_usage_path_t, link);		
-						  
-					if(!USB_HID_SAME_USAGE_PAGE(report_item->usage_page, 
-						path_item->usage_page) || ((only_page == 0) && 
-					    !USB_HID_SAME_USAGE(report_item->usage, 
-						path_item->usage))) {
-						
-							return 1;
-					} else {
-						report_link = report_link->prev;
-						path_link = path_link->prev;			
-					}
-			
-				}
-
-				if(path_link == &path->head) {
-					return EOK;
-				}
-				else {
-					return 1;
-				}						
-			
-			break;
-
-		default:
-			return EINVAL;
+		break;
+
+	default:
+		return EINVAL;
 	}
 }
@@ -418,6 +421,7 @@
 	path_link = usage_path->head.next;
 	while(path_link != &usage_path->head) {
-		path_item = list_get_instance(path_link, usb_hid_report_usage_path_t,
-		                              link);
+		path_item = list_get_instance(path_link, 
+			usb_hid_report_usage_path_t, link);
+
 		new_path_item = malloc(sizeof(usb_hid_report_usage_path_t));
 		if(new_path_item == NULL) {
