Index: uspace/lib/usb/include/usb/usb.h
===================================================================
--- uspace/lib/usb/include/usb/usb.h	(revision 52eead3e9c934a206319089e1822fed4612344dc)
+++ uspace/lib/usb/include/usb/usb.h	(revision 563d9d0a197dec694a11d47249e9f8d5420c1aee)
@@ -36,4 +36,5 @@
 #define LIBUSB_USB_H_
 
+#include <bool.h>
 #include <sys/types.h>
 #include <byteorder.h>
@@ -130,4 +131,15 @@
 } usb_target_t;
 
+/** Check USB target for allowed values (address and endpoint).
+ *
+ * @param target.
+ * @return True, if values are wihtin limits, false otherwise.
+ */
+static inline bool usb_target_is_valid(usb_target_t target)
+{
+	return !(target.endpoint > 15 || target.endpoint < 0
+	    || target.address >= USB11_ADDRESS_MAX || target.address < 0);
+}
+
 /** Compare USB targets (addresses and endpoints).
  *
Index: uspace/lib/usbhost/src/endpoint.c
===================================================================
--- uspace/lib/usbhost/src/endpoint.c	(revision 52eead3e9c934a206319089e1822fed4612344dc)
+++ uspace/lib/usbhost/src/endpoint.c	(revision 563d9d0a197dec694a11d47249e9f8d5420c1aee)
@@ -89,4 +89,5 @@
 {
 	assert(instance);
+	instance->destroy_hook = NULL;
 	instance->hc_data.data = NULL;
 	instance->hc_data.toggle_get = NULL;
Index: uspace/lib/usbhost/src/usb_endpoint_manager.c
===================================================================
--- uspace/lib/usbhost/src/usb_endpoint_manager.c	(revision 52eead3e9c934a206319089e1822fed4612344dc)
+++ uspace/lib/usbhost/src/usb_endpoint_manager.c	(revision 563d9d0a197dec694a11d47249e9f8d5420c1aee)
@@ -146,5 +146,5 @@
 	fibril_condvar_initialize(&instance->change);
 	instance->free_bw = available_bandwidth;
-	bool ht =
+	const bool ht =
 	    hash_table_create(&instance->ep_table, BUCKET_COUNT, MAX_KEYS, &op);
 	return ht ? EOK : ENOMEM;
@@ -160,22 +160,23 @@
 {
 	assert(ep);
-	size_t bw = bandwidth_count_usb11(ep->speed, ep->transfer_type,
+	const size_t bw = bandwidth_count_usb11(ep->speed, ep->transfer_type,
 	    data_size, ep->max_packet_size);
 	assert(instance);
+
+	fibril_mutex_lock(&instance->guard);
+
+	if (bw > instance->free_bw) {
+		fibril_mutex_unlock(&instance->guard);
+		return ENOSPC;
+	}
 
 	unsigned long key[MAX_KEYS] =
 	    {ep->address, ep->endpoint, ep->direction};
-	fibril_mutex_lock(&instance->guard);
-
-	link_t *item =
+
+	const link_t *item =
 	    hash_table_find(&instance->ep_table, key);
 	if (item != NULL) {
 		fibril_mutex_unlock(&instance->guard);
 		return EEXISTS;
-	}
-
-	if (bw > instance->free_bw) {
-		fibril_mutex_unlock(&instance->guard);
-		return ENOSPC;
 	}
 
@@ -211,6 +212,8 @@
 
 	node_t *node = hash_table_get_instance(item, node_t, link);
-	if (node->ep->active)
+	if (node->ep->active) {
+		fibril_mutex_unlock(&instance->guard);
 		return EBUSY;
+	}
 
 	instance->free_bw += node->bw;
@@ -230,10 +233,10 @@
 
 	fibril_mutex_lock(&instance->guard);
-	link_t *item = hash_table_find(&instance->ep_table, key);
+	const link_t *item = hash_table_find(&instance->ep_table, key);
 	if (item == NULL) {
 		fibril_mutex_unlock(&instance->guard);
 		return NULL;
 	}
-	node_t *node = hash_table_get_instance(item, node_t, link);
+	const node_t *node = hash_table_get_instance(item, node_t, link);
 	if (bw)
 		*bw = node->bw;
@@ -255,14 +258,14 @@
 {
 	assert(instance);
-	if (target.endpoint > 15 || target.endpoint < 0
-	    || target.address >= USB11_ADDRESS_MAX || target.address < 0) {
+	if (!usb_target_is_valid(target)) {
 		usb_log_error("Invalid data when checking for toggle reset.\n");
 		return;
 	}
 
+	assert(data);
 	switch (data[1])
 	{
-	case 0x01: /*clear feature*/
-		/* recipient is endpoint, value is zero (ENDPOINT_STALL) */
+	case 0x01: /* Clear Feature -- resets only cleared ep */
+		/* Recipient is endpoint, value is zero (ENDPOINT_STALL) */
 		if (((data[0] & 0xf) == 1) && ((data[2] | data[3]) == 0)) {
 			/* endpoint number is < 16, thus first byte is enough */
@@ -276,7 +279,7 @@
 	break;
 
-	case 0x9: /* set configuration */
-	case 0x11: /* set interface */
-		/* target must be device */
+	case 0x9: /* Set Configuration */
+	case 0x11: /* Set Interface */
+		/* Recipient must be device */
 		if ((data[0] & 0xf) == 0) {
 			usb_target_t reset_target =
