Index: uspace/lib/block/block.c
===================================================================
--- uspace/lib/block/block.c	(revision c67dbd622a32b92e827b239c60b0a0e72d711a01)
+++ uspace/lib/block/block.c	(revision feeac0d8cd6e0ce736779bc5f1dc701c5cf42ba6)
@@ -93,6 +93,5 @@
 	fibril_mutex_lock(&dcl_lock);
 	
-	list_foreach(dcl, cur) {
-		devcon_t *devcon = list_get_instance(cur, devcon_t, link);
+	list_foreach(dcl, link, devcon_t, devcon) {
 		if (devcon->service_id == service_id) {
 			fibril_mutex_unlock(&dcl_lock);
@@ -124,6 +123,5 @@
 	
 	fibril_mutex_lock(&dcl_lock);
-	list_foreach(dcl, cur) {
-		devcon_t *d = list_get_instance(cur, devcon_t, link);
+	list_foreach(dcl, link, devcon_t, d) {
 		if (d->service_id == service_id) {
 			fibril_mutex_unlock(&dcl_lock);
Index: uspace/lib/c/generic/adt/hash_table.c
===================================================================
--- uspace/lib/c/generic/adt/hash_table.c	(revision c67dbd622a32b92e827b239c60b0a0e72d711a01)
+++ uspace/lib/c/generic/adt/hash_table.c	(revision feeac0d8cd6e0ce736779bc5f1dc701c5cf42ba6)
@@ -227,10 +227,9 @@
 	
 	/* Check for duplicates. */
-	list_foreach(h->bucket[idx], cur) {
+	list_foreach(h->bucket[idx], link, ht_link_t, cur_link) {
 		/* 
 		 * We could filter out items using their hashes first, but 
 		 * calling equal() might very well be just as fast.
 		 */
-		ht_link_t *cur_link = member_to_inst(cur, ht_link_t, link);
 		if (h->op->equal(cur_link, item))
 			return false;
@@ -258,6 +257,5 @@
 	size_t idx = h->op->key_hash(key) % h->bucket_cnt;
 
-	list_foreach(h->bucket[idx], cur) {
-		ht_link_t *cur_link = member_to_inst(cur, ht_link_t, link);
+	list_foreach(h->bucket[idx], link, ht_link_t, cur_link) {
 		/* 
 		 * Is this is the item we are looking for? We could have first 
Index: uspace/lib/c/generic/adt/list.c
===================================================================
--- uspace/lib/c/generic/adt/list.c	(revision c67dbd622a32b92e827b239c60b0a0e72d711a01)
+++ uspace/lib/c/generic/adt/list.c	(revision feeac0d8cd6e0ce736779bc5f1dc701c5cf42ba6)
@@ -102,6 +102,8 @@
 	unsigned int count = 0;
 	
-	list_foreach(*list, link) {
+	link_t *link = list_first(list);
+	while (link != NULL) {
 		count++;
+		link = list_next(link, list);
 	}
 	
Index: uspace/lib/c/generic/cfg.c
===================================================================
--- uspace/lib/c/generic/cfg.c	(revision c67dbd622a32b92e827b239c60b0a0e72d711a01)
+++ uspace/lib/c/generic/cfg.c	(revision feeac0d8cd6e0ce736779bc5f1dc701c5cf42ba6)
@@ -83,7 +83,5 @@
 		return true;
 	
-	list_foreach(data->sections, link) {
-		const cfg_section_t *section = cfg_section_instance(link);
-		
+	cfg_file_foreach(data, section) {
 		if (!list_empty(&section->entries))
 			return false;
@@ -413,7 +411,5 @@
 const cfg_section_t *cfg_find_section(const cfg_file_t *data, const char *title)
 {
-	list_foreach(data->sections, link) {
-		const cfg_section_t *section = cfg_section_instance(link);
-		
+	cfg_file_foreach(data, section) {
 		if (str_cmp(section->title, title) == 0)
 			return section;
@@ -434,7 +430,5 @@
 const char *cfg_find_value(const cfg_section_t *section, const char *key)
 {
-	list_foreach(section->entries, link) {
-		const cfg_entry_t *entry = cfg_entry_instance(link);
-		
+	cfg_section_foreach(section, entry) {
 		if (str_cmp(entry->key, key) == 0)
 			return entry->value;
Index: uspace/lib/c/generic/devman.c
===================================================================
--- uspace/lib/c/generic/devman.c	(revision c67dbd622a32b92e827b239c60b0a0e72d711a01)
+++ uspace/lib/c/generic/devman.c	(revision feeac0d8cd6e0ce736779bc5f1dc701c5cf42ba6)
@@ -230,9 +230,5 @@
 	}
 	
-	match_id_t *match_id = NULL;
-	
-	list_foreach(match_ids->ids, link) {
-		match_id = list_get_instance(link, match_id_t, link);
-		
+	list_foreach(match_ids->ids, link, match_id_t, match_id) {
 		ipc_call_t answer2;
 		aid_t req2 = async_send_1(exch, DEVMAN_ADD_MATCH_ID,
Index: uspace/lib/c/generic/pio_trace.c
===================================================================
--- uspace/lib/c/generic/pio_trace.c	(revision c67dbd622a32b92e827b239c60b0a0e72d711a01)
+++ uspace/lib/c/generic/pio_trace.c	(revision feeac0d8cd6e0ce736779bc5f1dc701c5cf42ba6)
@@ -95,8 +95,5 @@
 	pio_regions_t *regions = get_regions();
 	fibril_rwlock_read_lock(&regions->guard);
-	list_foreach(regions->list, it) {
-		assert(it);
-		region_t *reg = region_instance(it);
-		assert(reg);
+	list_foreach(regions->list, link, region_t, reg) {
 		if ((r >= reg->base) && (r < reg->base + reg->size)) {
 			if (reg->log)
@@ -131,10 +128,8 @@
 	fibril_rwlock_write_lock(&regions->guard);
 	list_foreach_safe(regions->list, it, next) {
-		assert(it);
 		region_t *reg = region_instance(it);
-		assert(reg);
 		if (r >= reg->base && (r < reg->base + reg->size)) {
-				list_remove(&reg->link);
-				region_destroy(reg);
+			list_remove(&reg->link);
+			region_destroy(reg);
 		}
 	}
Index: uspace/lib/c/include/adt/list.h
===================================================================
--- uspace/lib/c/include/adt/list.h	(revision c67dbd622a32b92e827b239c60b0a0e72d711a01)
+++ uspace/lib/c/include/adt/list.h	(revision feeac0d8cd6e0ce736779bc5f1dc701c5cf42ba6)
@@ -67,7 +67,9 @@
 	((type *) (((void *)(link)) - list_link_to_void(&(((type *) NULL)->member))))
 
-#define list_foreach(list, iterator) \
-	for (link_t *iterator = (list).head.next; \
-	    iterator != &(list).head; iterator = iterator->next)
+#define list_foreach(list, member, itype, iterator) \
+	for (itype *iterator = NULL; iterator == NULL; iterator =(itype *)1) \
+	    for (link_t *_link = (list).head.next; \
+	    iterator = list_get_instance(_link, itype, member), \
+	    _link != &(list).head; _link = _link->next)
 
 /** Unlike list_foreach(), allows removing items while traversing a list.
@@ -238,5 +240,29 @@
 static inline link_t *list_last(list_t *list)
 {
-	return ((list->head.prev == &list->head) ? NULL : list->head.prev);
+	return (list->head.prev == &list->head) ? NULL : list->head.prev;
+}
+
+/** Get next item in list.
+ *
+ * @param link Current item link
+ * @param list List containing @a link
+ *
+ * @return Next item or NULL if @a link is the last item.
+ */
+static inline link_t *list_next(link_t *link, const list_t *list)
+{
+	return (link->next == &list->head) ? NULL : link->next;
+}
+
+/** Get previous item in list.
+ *
+ * @param link Current item link
+ * @param list List containing @a link
+ *
+ * @return Previous item or NULL if @a link is the first item.
+ */
+static inline link_t *list_prev(link_t *link, const list_t *list)
+{
+	return (link->prev == &list->head) ? NULL : link->prev;
 }
 
@@ -308,9 +334,11 @@
 	unsigned int cnt = 0;
 	
-	list_foreach(*list, link) {
+	link_t *link = list_first(list);
+	while (link != NULL) {
 		if (cnt == n)
 			return link;
 		
 		cnt++;
+		link = list_next(link, list);
 	}
 	
Index: uspace/lib/c/include/cfg.h
===================================================================
--- uspace/lib/c/include/cfg.h	(revision c67dbd622a32b92e827b239c60b0a0e72d711a01)
+++ uspace/lib/c/include/cfg.h	(revision feeac0d8cd6e0ce736779bc5f1dc701c5cf42ba6)
@@ -80,5 +80,5 @@
 
 #define cfg_file_foreach(file, cur) \
-	list_foreach((file)->sections, (cur))
+	list_foreach((file)->sections, link, const cfg_section_t, (cur))
 
 #define cfg_section_instance(cur) \
@@ -86,5 +86,5 @@
 
 #define cfg_section_foreach(section, cur) \
-	list_foreach((section)->entries, (cur))
+	list_foreach((section)->entries, link, const cfg_entry_t, (cur))
 
 #define cfg_entry_instance(cur) \
Index: uspace/lib/draw/drawctx.c
===================================================================
--- uspace/lib/draw/drawctx.c	(revision c67dbd622a32b92e827b239c60b0a0e72d711a01)
+++ uspace/lib/draw/drawctx.c	(revision feeac0d8cd6e0ce736779bc5f1dc701c5cf42ba6)
@@ -188,6 +188,5 @@
 	 * transferred to the original surface. */
 
-	list_foreach(*((list_t *) path), link) {
-		path_step_t *step = (path_step_t *) link;
+	list_foreach(*((list_t *) path), link, path_step_t, step) {
 		switch (step->type) {
 		case PATH_STEP_MOVETO:
Index: uspace/lib/drv/generic/driver.c
===================================================================
--- uspace/lib/drv/generic/driver.c	(revision c67dbd622a32b92e827b239c60b0a0e72d711a01)
+++ uspace/lib/drv/generic/driver.c	(revision feeac0d8cd6e0ce736779bc5f1dc701c5cf42ba6)
@@ -98,10 +98,7 @@
 static ddf_dev_t *driver_get_device(devman_handle_t handle)
 {
-	ddf_dev_t *dev = NULL;
-	
 	assert(fibril_mutex_is_locked(&devices_mutex));
 	
-	list_foreach(devices, link) {
-		dev = list_get_instance(link, ddf_dev_t, link);
+	list_foreach(devices, link, ddf_dev_t, dev) {
 		if (dev->handle == handle)
 			return dev;
@@ -113,10 +110,7 @@
 static ddf_fun_t *driver_get_function(devman_handle_t handle)
 {
-	ddf_fun_t *fun = NULL;
-	
 	assert(fibril_mutex_is_locked(&functions_mutex));
 	
-	list_foreach(functions, link) {
-		fun = list_get_instance(link, ddf_fun_t, link);
+	list_foreach(functions, link, ddf_fun_t, fun) {
 		if (fun->handle == handle)
 			return fun;
Index: uspace/lib/drv/generic/interrupt.c
===================================================================
--- uspace/lib/drv/generic/interrupt.c	(revision c67dbd622a32b92e827b239c60b0a0e72d711a01)
+++ uspace/lib/drv/generic/interrupt.c	(revision feeac0d8cd6e0ce736779bc5f1dc701c5cf42ba6)
@@ -138,10 +138,7 @@
     interrupt_context_list_t *list, int id)
 {
-	interrupt_context_t *ctx;
-	
-	fibril_mutex_lock(&list->mutex);
-	
-	list_foreach(list->contexts, link) {
-		ctx = list_get_instance(link, interrupt_context_t, link);
+	fibril_mutex_lock(&list->mutex);
+	
+	list_foreach(list->contexts, link, interrupt_context_t, ctx) {
 		if (ctx->id == id) {
 			fibril_mutex_unlock(&list->mutex);
@@ -157,10 +154,7 @@
     interrupt_context_list_t *list, ddf_dev_t *dev, int irq)
 {
-	interrupt_context_t *ctx;
-	
-	fibril_mutex_lock(&list->mutex);
-	
-	list_foreach(list->contexts, link) {
-		ctx = list_get_instance(link, interrupt_context_t, link);
+	fibril_mutex_lock(&list->mutex);
+	
+	list_foreach(list->contexts, link, interrupt_context_t, ctx) {
 		if (ctx->irq == irq && ctx->dev == dev) {
 			fibril_mutex_unlock(&list->mutex);
Index: uspace/lib/fs/libfs.c
===================================================================
--- uspace/lib/fs/libfs.c	(revision c67dbd622a32b92e827b239c60b0a0e72d711a01)
+++ uspace/lib/fs/libfs.c	(revision feeac0d8cd6e0ce736779bc5f1dc701c5cf42ba6)
@@ -882,8 +882,5 @@
 
 	fibril_mutex_lock(&instances_mutex);
-	list_foreach(instances_list, link) {
-		fs_instance_t *cur = list_get_instance(link, fs_instance_t,
-		    link);
-
+	list_foreach(instances_list, link, fs_instance_t, cur) {
 		if (cur->service_id == service_id) {
 			fibril_mutex_unlock(&instances_mutex);
@@ -908,8 +905,5 @@
 {
 	fibril_mutex_lock(&instances_mutex);
-	list_foreach(instances_list, link) {
-		fs_instance_t *inst = list_get_instance(link, fs_instance_t,
-		    link);
-
+	list_foreach(instances_list, link, fs_instance_t, inst) {
 		if (inst->service_id == service_id) {
 			*idp = inst->data;
@@ -925,8 +919,5 @@
 {
 	fibril_mutex_lock(&instances_mutex);
-	list_foreach(instances_list, link) {
-		fs_instance_t *inst = list_get_instance(link, fs_instance_t,
-		    link);
-
+	list_foreach(instances_list, link, fs_instance_t, inst) {
 		if (inst->service_id == service_id) {
 			list_remove(&inst->link);
Index: uspace/lib/graph/graph.c
===================================================================
--- uspace/lib/graph/graph.c	(revision c67dbd622a32b92e827b239c60b0a0e72d711a01)
+++ uspace/lib/graph/graph.c	(revision feeac0d8cd6e0ce736779bc5f1dc701c5cf42ba6)
@@ -165,8 +165,7 @@
 
 	fibril_mutex_lock(&visualizer_list_mtx);
-	list_foreach(visualizer_list, link) {
-		visualizer_t *cur = list_get_instance(link, visualizer_t, link);
-		if (cur->reg_svc_handle == handle) {
-			vs = cur;
+	list_foreach(visualizer_list, link, visualizer_t, vcur) {
+		if (vcur->reg_svc_handle == handle) {
+			vs = vcur;
 			break;
 		}
@@ -182,8 +181,7 @@
 
 	fibril_mutex_lock(&renderer_list_mtx);
-	list_foreach(renderer_list, link) {
-		renderer_t *cur = list_get_instance(link, renderer_t, link);
-		if (cur->reg_svc_handle == handle) {
-			rnd = cur;
+	list_foreach(renderer_list, link, renderer_t, rcur) {
+		if (rcur->reg_svc_handle == handle) {
+			rnd = rcur;
 			break;
 		}
@@ -322,6 +320,5 @@
 	fibril_mutex_lock(&vs->mode_mtx);
 	vslmode_list_element_t *mode_elem = NULL;
-	list_foreach(vs->modes, link) {
-		vslmode_list_element_t *cur = list_get_instance(link, vslmode_list_element_t, link);
+	list_foreach(vs->modes, link, vslmode_list_element_t, cur) {
 		if (cur->mode.index == vs->def_mode_idx) {
 			mode_elem = cur;
@@ -382,6 +379,5 @@
 	fibril_mutex_lock(&vs->mode_mtx);
 	vslmode_list_element_t *mode_elem = NULL;
-	list_foreach(vs->modes, link) {
-		vslmode_list_element_t *cur = list_get_instance(link, vslmode_list_element_t, link);
+	list_foreach(vs->modes, link, vslmode_list_element_t, cur) {
 		if (cur->mode.index == mode_idx) {
 			mode_elem = cur;
@@ -425,6 +421,5 @@
 	fibril_mutex_lock(&vs->mode_mtx);
 	vslmode_list_element_t *mode_elem = NULL;
-	list_foreach(vs->modes, link) {
-		vslmode_list_element_t *cur = list_get_instance(link, vslmode_list_element_t, link);
+	list_foreach(vs->modes, link, vslmode_list_element_t, cur) {
 		if (cur->mode.index == mode_idx) {
 			mode_elem = cur;
Index: uspace/lib/gui/connection.c
===================================================================
--- uspace/lib/gui/connection.c	(revision c67dbd622a32b92e827b239c60b0a0e72d711a01)
+++ uspace/lib/gui/connection.c	(revision feeac0d8cd6e0ce736779bc5f1dc701c5cf42ba6)
@@ -65,6 +65,5 @@
 
 	signal_node_t *sig_node = NULL;
-	list_foreach(connection_list, link) {
-		signal_node_t *cur = list_get_instance(link, signal_node_t, link);
+	list_foreach(connection_list, link, signal_node_t, cur) {
 		if (cur->signal == signal) {
 			sig_node = cur;
@@ -88,6 +87,5 @@
 
 	slot_node_t *slt_node = NULL;
-	list_foreach(sig_node->slots, link) {
-		slot_node_t *cur = list_get_instance(link, slot_node_t, link);
+	list_foreach(sig_node->slots, link, slot_node_t, cur) {
 		if (cur->widget == widget && cur->slot == slot) {
 			slt_node = cur;
@@ -121,6 +119,5 @@
 
 	signal_node_t *sig_node = NULL;
-	list_foreach(connection_list, link) {
-		signal_node_t *cur = list_get_instance(link, signal_node_t, link);
+	list_foreach(connection_list, link, signal_node_t, cur) {
 		if (cur->signal == signal) {
 			sig_node = cur;
@@ -135,6 +132,5 @@
 
 	slot_node_t *slt_node = NULL;
-	list_foreach(sig_node->slots, link) {
-		slot_node_t *cur = list_get_instance(link, slot_node_t, link);
+	list_foreach(sig_node->slots, link, slot_node_t, cur) {
 		if (cur->widget == widget && cur->slot == slot) {
 			slt_node = cur;
@@ -164,6 +160,5 @@
 
 	signal_node_t *sig_node = NULL;
-	list_foreach(connection_list, link) {
-		signal_node_t *cur = list_get_instance(link, signal_node_t, link);
+	list_foreach(connection_list, link, signal_node_t, cur) {
 		if (cur->signal == signal) {
 			sig_node = cur;
@@ -177,6 +172,5 @@
 	}
 
-	list_foreach(sig_node->slots, link) {
-		slot_node_t *cur = list_get_instance(link, slot_node_t, link);
+	list_foreach(sig_node->slots, link, slot_node_t, cur) {
 		cur->slot(cur->widget, data);
 	}
@@ -190,6 +184,5 @@
 
 	signal_node_t *sig_node = NULL;
-	list_foreach(connection_list, link) {
-		signal_node_t *cur = list_get_instance(link, signal_node_t, link);
+	list_foreach(connection_list, link, signal_node_t, cur) {
 		if (cur->signal == signal) {
 			sig_node = cur;
@@ -203,7 +196,5 @@
 	}
 
-	list_foreach(sig_node->slots, link) {
-		slot_node_t *cur = list_get_instance(link, slot_node_t, link);
-
+	list_foreach(sig_node->slots, link, slot_node_t, cur) {
 		void *data_copy = NULL;
 		if (data != NULL) {
Index: uspace/lib/gui/grid.c
===================================================================
--- uspace/lib/gui/grid.c	(revision c67dbd622a32b92e827b239c60b0a0e72d711a01)
+++ uspace/lib/gui/grid.c	(revision feeac0d8cd6e0ce736779bc5f1dc701c5cf42ba6)
@@ -298,6 +298,5 @@
 	paint_internal(widget);
 	
-	list_foreach(widget->children, link) {
-		widget_t *child = list_get_instance(link, widget_t, link);
+	list_foreach(widget->children, link, widget_t, child) {
 		child->repaint(child);
 	}
Index: uspace/lib/gui/terminal.c
===================================================================
--- uspace/lib/gui/terminal.c	(revision c67dbd622a32b92e827b239c60b0a0e72d711a01)
+++ uspace/lib/gui/terminal.c	(revision feeac0d8cd6e0ce736779bc5f1dc701c5cf42ba6)
@@ -685,7 +685,5 @@
 	terminal_t *term = NULL;
 	
-	list_foreach(terms, link) {
-		terminal_t *cur = list_get_instance(link, terminal_t, link);
-		
+	list_foreach(terms, link, terminal_t, cur) {
 		if (cur->dsid == (service_id_t) IPC_GET_ARG1(*icall)) {
 			term = cur;
Index: uspace/lib/gui/window.c
===================================================================
--- uspace/lib/gui/window.c	(revision c67dbd622a32b92e827b239c60b0a0e72d711a01)
+++ uspace/lib/gui/window.c	(revision feeac0d8cd6e0ce736779bc5f1dc701c5cf42ba6)
@@ -137,6 +137,5 @@
 {
 	if (widget->window->is_decorated) {
-		list_foreach(widget->children, link) {
-			widget_t *child = list_get_instance(link, widget_t, link);
+		list_foreach(widget->children, link, widget_t, child) {
 			child->rearrange(child, 
 			    widget->hpos + border_thickness,
@@ -146,6 +145,5 @@
 		}
 	} else {
-		list_foreach(widget->children, link) {
-			widget_t *child = list_get_instance(link, widget_t, link);
+		list_foreach(widget->children, link, widget_t, child) {
 			child->rearrange(child, widget->hpos, widget->vpos,
 			    widget->width, widget->height);
@@ -160,6 +158,5 @@
 	if (widget->window->is_decorated) {
 		paint_internal(widget);
-		list_foreach(widget->children, link) {
-			widget_t *child = list_get_instance(link, widget_t, link);
+		list_foreach(widget->children, link, widget_t, child) {
 			child->rearrange(child, 
 			    hpos + border_thickness,
@@ -169,6 +166,5 @@
 		}
 	} else {
-		list_foreach(widget->children, link) {
-			widget_t *child = list_get_instance(link, widget_t, link);
+		list_foreach(widget->children, link, widget_t, child) {
 			child->rearrange(child, hpos, vpos, width, height);
 		}
@@ -181,6 +177,5 @@
 		paint_internal(widget);
 	}
-	list_foreach(widget->children, link) {
-		widget_t *child = list_get_instance(link, widget_t, link);
+	list_foreach(widget->children, link, widget_t, child) {
 		child->repaint(child);
 	}
@@ -268,12 +263,10 @@
 			win_grab(widget->window->osess, event.pos_id, flags);
 		} else {
-			list_foreach(widget->children, link) {
-				widget_t *child = list_get_instance(link, widget_t, link);
+			list_foreach(widget->children, link, widget_t, child) {
 				child->handle_position_event(child, event);
 			}
 		}
 	} else {
-		list_foreach(widget->children, link) {
-			widget_t *child = list_get_instance(link, widget_t, link);
+		list_foreach(widget->children, link, widget_t, child) {
 			child->handle_position_event(child, event);
 		}
Index: uspace/lib/usbdev/src/recognise.c
===================================================================
--- uspace/lib/usbdev/src/recognise.c	(revision c67dbd622a32b92e827b239c60b0a0e72d711a01)
+++ uspace/lib/usbdev/src/recognise.c	(revision feeac0d8cd6e0ce736779bc5f1dc701c5cf42ba6)
@@ -383,6 +383,5 @@
 		goto failure;
 	
-	list_foreach(match_ids.ids, id_link) {
-		match_id_t *match_id = list_get_instance(id_link, match_id_t, link);
+	list_foreach(match_ids.ids, link, match_id_t, match_id) {
 		rc = ddf_fun_add_match_id(child, match_id->id, match_id->score);
 		if (rc != EOK) {
Index: uspace/lib/usbhid/src/hiddescriptor.c
===================================================================
--- uspace/lib/usbhid/src/hiddescriptor.c	(revision c67dbd622a32b92e827b239c60b0a0e72d711a01)
+++ uspace/lib/usbhid/src/hiddescriptor.c	(revision feeac0d8cd6e0ce736779bc5f1dc701c5cf42ba6)
@@ -333,10 +333,6 @@
 	}
 
-	usb_hid_report_description_t *report_des = NULL;
-	
-	list_foreach(report->reports, report_it) {
-		report_des = list_get_instance(report_it,
-				usb_hid_report_description_t, reports_link);
-
+	list_foreach(report->reports, reports_link,
+	    usb_hid_report_description_t, report_des) {
 		// if report id not set, return the first of the type
 		if(((report_des->report_id == report_id) || (report_id == 0)) && 
@@ -902,6 +898,4 @@
 void usb_hid_descriptor_print_list(list_t *list)
 {
-	usb_hid_report_field_t *report_item;
-
 	if(list == NULL || list_empty(list)) {
 	    usb_log_debug("\tempty\n");
@@ -909,8 +903,6 @@
 	}
 
-        list_foreach(*list, item) {
-		report_item = list_get_instance(item, usb_hid_report_field_t,
-				ritems_link);
-
+        list_foreach(*list, ritems_link, usb_hid_report_field_t,
+    	    report_item) {
 		usb_log_debug("\t\tOFFSET: %X\n", report_item->offset);
 		usb_log_debug("\t\tSIZE: %zu\n", report_item->size);
@@ -937,7 +929,5 @@
 
 		usb_log_debug("\n");
-
-	}
-
+	}
 }
 
@@ -951,13 +941,9 @@
 void usb_hid_descriptor_print(usb_hid_report_t *report)
 {
-	if(report == NULL) {
+	if (report == NULL)
 		return;
-	}
-
-	usb_hid_report_description_t *report_des;
-
-	list_foreach(report->reports, report_it) {
-		report_des = list_get_instance(report_it,
-			usb_hid_report_description_t, reports_link);
+
+	list_foreach(report->reports, reports_link,
+	    usb_hid_report_description_t, report_des) {
 		usb_log_debug("Report ID: %d\n", report_des->report_id);
 		usb_log_debug("\tType: %d\n", report_des->type);
Index: uspace/lib/usbhid/src/hidparser.c
===================================================================
--- uspace/lib/usbhid/src/hidparser.c	(revision c67dbd622a32b92e827b239c60b0a0e72d711a01)
+++ uspace/lib/usbhid/src/hidparser.c	(revision feeac0d8cd6e0ce736779bc5f1dc701c5cf42ba6)
@@ -130,9 +130,7 @@
     size_t size, uint8_t *report_id)
 {
-	usb_hid_report_field_t *item;
-
 	usb_hid_report_description_t *report_des;
 	usb_hid_report_type_t type = USB_HID_REPORT_TYPE_INPUT;
-	
+
 	if (report == NULL) {
 		return EINVAL;
@@ -153,15 +151,14 @@
 
 	/* read data */
-	list_foreach(report_des->report_items, list_item) {
-		item = list_get_instance(list_item, usb_hid_report_field_t, 
-		    ritems_link);
+	list_foreach(report_des->report_items, ritems_link,
+	    usb_hid_report_field_t, item) {
 
 		if (USB_HID_ITEM_FLAG_CONSTANT(item->item_flags) == 0) {
-			
+
 			if (USB_HID_ITEM_FLAG_VARIABLE(item->item_flags) == 0) {
 				/* array */
 				item->value = 
 					usb_hid_translate_data(item, data);
-		
+
 				item->usage = USB_HID_EXTENDED_USAGE(
 				    item->usages[item->value -
@@ -184,9 +181,9 @@
 				/* variable item */
 				item->value = usb_hid_translate_data(item, 
-				    data);				
-			}			
+				    data);
+			}
 		}
 	}
-	
+
 	return EOK;
 }
@@ -295,8 +292,6 @@
 	usb_hid_report_description_t *report_des = NULL;
 
-	list_foreach(report->reports, report_it) {
-		report_des = list_get_instance(report_it,
-		    usb_hid_report_description_t, reports_link);
-		
+	list_foreach(report->reports, reports_link,
+	    usb_hid_report_description_t, report_des) {
 		if ((report_des->report_id == report_id) &&
 		    (report_des->type == USB_HID_REPORT_TYPE_OUTPUT)) {
@@ -345,5 +340,5 @@
 	int length;
 	int32_t tmp_value;
-	
+
 	if (report == NULL) {
 		return EINVAL;
@@ -351,5 +346,5 @@
 
 	if (report->use_report_ids != 0) {
-		buffer[0] = report_id;		
+		buffer[0] = report_id;
 	}
 
@@ -357,15 +352,11 @@
 	report_des = usb_hid_report_find_description(report, report_id, 
 	    USB_HID_REPORT_TYPE_OUTPUT);
-	
+
 	if (report_des == NULL) {
 		return EINVAL;
 	}
 
-	usb_hid_report_field_t *report_item;
-
-	list_foreach(report_des->report_items, item) {
-		report_item = list_get_instance(item, usb_hid_report_field_t,
-		    ritems_link);
-
+	list_foreach(report_des->report_items, ritems_link,
+	    usb_hid_report_field_t, report_item) {
 		value = usb_hid_translate_data_reverse(report_item, 
 		    report_item->value);
@@ -373,5 +364,5 @@
 		offset = report_des->bit_length - report_item->offset - 1;
 		length = report_item->size;
-		
+
 		usb_log_debug("\ttranslated value: %x\n", value);
 
@@ -382,7 +373,7 @@
 			}
 			size_t shift = 8 - offset % 8 - length;
-			value = value << shift;							
+			value = value << shift;
 			value = value & (((1 << length) - 1) << shift);
-				
+
 			uint8_t mask = 0;
 			mask = 0xff - (((1 << length) - 1) << shift);
@@ -400,5 +391,5 @@
 
 					tmp_value = tmp_value << (offset % 8);
-	
+
 					mask = ~(((1 << (8 - (offset % 8))) - 1)
 					    << (offset % 8));
@@ -407,5 +398,5 @@
 					    tmp_value;
 				} else if (i == ((offset + length - 1) / 8)) {
-					
+
 					value = value >> (length - 
 					    ((offset + length) % 8));
@@ -413,5 +404,5 @@
 					value = value & ((1 << (length - 
 					    ((offset + length) % 8))) - 1);
-				
+
 					mask = (1 << (length - 
 					    ((offset + length) % 8))) - 1;
@@ -427,5 +418,5 @@
 		report_item->value = 0;
 	}
-	
+
 	return EOK;
 }
Index: uspace/lib/usbhid/src/hidpath.c
===================================================================
--- uspace/lib/usbhid/src/hidpath.c	(revision c67dbd622a32b92e827b239c60b0a0e72d711a01)
+++ uspace/lib/usbhid/src/hidpath.c	(revision feeac0d8cd6e0ce736779bc5f1dc701c5cf42ba6)
@@ -176,9 +176,6 @@
 	usb_log_debug("\tLENGTH: %d\n", path->depth);
 
-	usb_hid_report_usage_path_t *path_item;
-
-	list_foreach(path->items, item) {
-		path_item = list_get_instance(item, usb_hid_report_usage_path_t,
-			rpath_items_link);
+	list_foreach(path->items, rpath_items_link,
+	    usb_hid_report_usage_path_t, path_item) {
 
 		usb_log_debug("\tUSAGE_PAGE: %X\n", path_item->usage_page);
@@ -237,16 +234,15 @@
 			usb_hid_report_usage_path_t, rpath_items_link);
 
-		list_foreach(report_path->items, report_link) {
-			report_item = list_get_instance(report_link,
-				usb_hid_report_usage_path_t, rpath_items_link);
-				
+		list_foreach(report_path->items, rpath_items_link,
+		    usb_hid_report_usage_path_t, report_item) {
+
 			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)) {
-							
+
 						return EOK;
 					}
@@ -266,17 +262,17 @@
 			return 1;
 		}
-		
+
 	/* path is prefix of the report_path */
 	case USB_HID_PATH_COMPARE_BEGIN:
-	
+
 		report_link = report_path->items.head.next;
 		path_link = path->items.head.next;
-			
+
 		while((report_link != &report_path->items.head) && 
 		      (path_link != &path->items.head)) {
-					  
+
 			report_item = list_get_instance(report_link, 
 				usb_hid_report_usage_path_t, rpath_items_link);
-					  
+
 			path_item = list_get_instance(path_link,
        				usb_hid_report_usage_path_t, rpath_items_link);
@@ -286,12 +282,10 @@
 			    !USB_HID_SAME_USAGE(report_item->usage, 
 				path_item->usage))) {
-			
+
 				return 1;
-			} 
-			else {
+			} else {
 				report_link = report_link->next;
-				path_link = path_link->next;			
+				path_link = path_link->next;
 			}
-			
 		}
 
@@ -300,5 +294,5 @@
 		   ((report_link == &report_path->items.head) && 
 			(path_link == &path->items.head))) {
-				
+
 			return EOK;
 		}
@@ -405,5 +399,4 @@
 	usb_hid_report_path_t *usage_path)
 {
-	usb_hid_report_usage_path_t *path_item;
 	usb_hid_report_usage_path_t *new_path_item;
 	usb_hid_report_path_t *new_usage_path = usb_hid_report_path ();
@@ -419,7 +412,6 @@
 	}
 
-	list_foreach(usage_path->items, path_link) {
-		path_item = list_get_instance(path_link,
-			usb_hid_report_usage_path_t, rpath_items_link);
+	list_foreach(usage_path->items, rpath_items_link,
+	    usb_hid_report_usage_path_t, path_item) {
 
 		new_path_item = malloc(sizeof(usb_hid_report_usage_path_t));
Index: uspace/lib/usbhost/src/usb_endpoint_manager.c
===================================================================
--- uspace/lib/usbhost/src/usb_endpoint_manager.c	(revision c67dbd622a32b92e827b239c60b0a0e72d711a01)
+++ uspace/lib/usbhost/src/usb_endpoint_manager.c	(revision feeac0d8cd6e0ce736779bc5f1dc701c5cf42ba6)
@@ -90,6 +90,5 @@
 	if (address < 0)
 		return NULL;
-	list_foreach(*get_list(instance, address), iterator) {
-		endpoint_t *ep = endpoint_get_instance(iterator);
+	list_foreach(*get_list(instance, address), link, endpoint_t, ep) {
 		if (ep_match(ep, address, endpoint, direction))
 			return ep;
@@ -196,6 +195,6 @@
 			fibril_mutex_lock(&instance->guard);
 			/* endpoint number is < 16, thus first byte is enough */
-			list_foreach(*get_list(instance, target.address), it) {
-				endpoint_t *ep = endpoint_get_instance(it);
+			list_foreach(*get_list(instance, target.address),
+			    link, endpoint_t, ep) {
 				if ((ep->address == target.address)
 				    && (ep->endpoint = data[4])) {
@@ -216,6 +215,6 @@
 		if ((data[0] & 0xf) == 0) {
 			fibril_mutex_lock(&instance->guard);
-			list_foreach(*get_list(instance, target.address), it) {
-				endpoint_t *ep = endpoint_get_instance(it);
+			list_foreach(*get_list(instance, target.address),
+			    link, endpoint_t, ep) {
 				if (ep->address == target.address) {
 					endpoint_toggle_set(ep,0);
@@ -408,11 +407,19 @@
     usb_address_t address, void (*callback)(endpoint_t *, void *), void *arg)
 {
+	list_t *list;
+	link_t *link;
+	link_t *next;
+
 	assert(address >= 0);
 	assert(instance);
 	fibril_mutex_lock(&instance->guard);
-	list_foreach(*get_list(instance, address), iterator) {
-		endpoint_t *ep = endpoint_get_instance(iterator);
+
+	list = get_list(instance, address);
+	link = list_first(list);
+	while (link != NULL) {
+		endpoint_t *ep = list_get_instance(link, endpoint_t, link);
+		next = list_next(link, list);
+
 		if (ep->address == address) {
-			iterator = iterator->next;
 			list_remove(&ep->link);
 			if (callback)
@@ -420,4 +427,5 @@
 			endpoint_destroy(ep);
 		}
+		link = next;
 	}
 	fibril_mutex_unlock(&instance->guard);
