Index: kernel/generic/include/adt/list.h
===================================================================
--- kernel/generic/include/adt/list.h	(revision 1d1bb0f43b969df62916cc6de4c6e8c2bc054416)
+++ kernel/generic/include/adt/list.h	(revision b72efe87f3e33beaa3b0d0cf7c8b598a58f6a6de)
@@ -71,4 +71,7 @@
 	    iterator != &(list).head; iterator = iterator->next)
 
+#define assert_link_not_used(link) \
+	assert((link)->prev == NULL && (link)->next == NULL)
+
 /** Initialize doubly-linked circular list link
  *
Index: kernel/generic/src/adt/hash_table.c
===================================================================
--- kernel/generic/src/adt/hash_table.c	(revision 1d1bb0f43b969df62916cc6de4c6e8c2bc054416)
+++ kernel/generic/src/adt/hash_table.c	(revision b72efe87f3e33beaa3b0d0cf7c8b598a58f6a6de)
@@ -147,7 +147,8 @@
 	ASSERT(keys <= h->max_keys);
 	
+	
 	if (keys == h->max_keys) {
 		link_t *cur;
-	
+		
 		/*
 		 * All keys are known, hash_table_find() can be used to find the entry.
@@ -168,5 +169,7 @@
 	 */
 	for (chain = 0; chain < h->entries; chain++) {
-		list_foreach(h->entry[chain], cur) {
+		link_t *cur;
+		for (cur = h->entry[chain].head.next; cur != &h->entry[chain].head;
+		    cur = cur->next) {
 			if (h->op->compare(key, keys, cur)) {
 				link_t *hlp;
Index: kernel/generic/src/adt/list.c
===================================================================
--- kernel/generic/src/adt/list.c	(revision 1d1bb0f43b969df62916cc6de4c6e8c2bc054416)
+++ kernel/generic/src/adt/list.c	(revision b72efe87f3e33beaa3b0d0cf7c8b598a58f6a6de)
@@ -90,4 +90,22 @@
 }
 
+/** Count list items
+ *
+ * Return the number of items in the list.
+ *
+ * @param list		List to count.
+ * @return		Number of items in the list.
+ */
+unsigned int list_count(const list_t *list)
+{
+	unsigned int count = 0;
+	
+	list_foreach(*list, link) {
+		count++;
+	}
+	
+	return count;
+}
+
 /** @}
  */
Index: uspace/app/edit/sheet.c
===================================================================
--- uspace/app/edit/sheet.c	(revision 1d1bb0f43b969df62916cc6de4c6e8c2bc054416)
+++ uspace/app/edit/sheet.c	(revision b72efe87f3e33beaa3b0d0cf7c8b598a58f6a6de)
@@ -75,5 +75,5 @@
 		return ENOMEM;
 
-	list_initialize(&sh->tags_head);
+	list_initialize(&sh->tags);
 
 	return EOK;
@@ -97,5 +97,4 @@
 	char *ipp;
 	size_t sz;
-	link_t *link;
 	tag_t *tag;
 	char *newp;
@@ -121,6 +120,5 @@
 	/* Adjust tags. */
 
-	link = sh->tags_head.next;
-	while (link != &sh->tags_head) {
+	list_foreach(sh->tags, link) {
 		tag = list_get_instance(link, tag_t, link);
 
@@ -129,6 +127,4 @@
 		else if (tag->b_off == pos->b_off && dir == dir_before)
 			tag->b_off += sz;
-
-		link = link->next;
 	}
 
@@ -150,5 +146,4 @@
 	char *spp;
 	size_t sz;
-	link_t *link;
 	tag_t *tag;
 	char *newp;
@@ -162,6 +157,5 @@
 
 	/* Adjust tags. */
-	link = sh->tags_head.next;
-	while (link != &sh->tags_head) {
+	list_foreach(sh->tags, link) {
 		tag = list_get_instance(link, tag_t, link);
 
@@ -170,6 +164,4 @@
 		else if (tag->b_off >= spos->b_off)
 			tag->b_off = spos->b_off;
-
-		link = link->next;
 	}
 
@@ -328,5 +320,5 @@
 	tag->b_off = pt->b_off;
 	tag->sh = sh;
-	list_append(&tag->link, &sh->tags_head);
+	list_append(&tag->link, &sh->tags);
 }
 
Index: uspace/app/edit/sheet.h
===================================================================
--- uspace/app/edit/sheet.h	(revision 1d1bb0f43b969df62916cc6de4c6e8c2bc054416)
+++ uspace/app/edit/sheet.h	(revision b72efe87f3e33beaa3b0d0cf7c8b598a58f6a6de)
@@ -57,5 +57,5 @@
 	char *data;
 
-	link_t tags_head;
+	list_t tags;
 } sheet_t;
 
@@ -91,5 +91,5 @@
 	/* Note: This structure is opaque for the user. */
 
-	/** Link to list of all tags in the sheet (see sheet_t.tags_head) */
+	/** Link to list of all tags in the sheet (see sheet_t.tags) */
 	link_t link;
 	sheet_t *sh;
Index: uspace/app/sbi/src/compat.h
===================================================================
--- uspace/app/sbi/src/compat.h	(revision 1d1bb0f43b969df62916cc6de4c6e8c2bc054416)
+++ uspace/app/sbi/src/compat.h	(revision b72efe87f3e33beaa3b0d0cf7c8b598a58f6a6de)
@@ -38,4 +38,7 @@
 #ifdef __HELENOS__
 
+#define list sbi_list
+#define list_t sbi_list_t
+
 /*
  * Avoid name conflicts with ADT library.
@@ -44,4 +47,6 @@
 #define list_prepend sbi_list_prepend
 #define list_remove sbi_list_remove
+#define list_first sbi_list_first
+#define list_last sbi_list_last
 
 #endif
Index: uspace/app/sbi/src/list_t.h
===================================================================
--- uspace/app/sbi/src/list_t.h	(revision 1d1bb0f43b969df62916cc6de4c6e8c2bc054416)
+++ uspace/app/sbi/src/list_t.h	(revision b72efe87f3e33beaa3b0d0cf7c8b598a58f6a6de)
@@ -30,4 +30,6 @@
 #define LIST_T_H_
 
+#include "compat.h"
+
 typedef struct list_node {
 	struct list_node *prev, *next;
Index: uspace/app/tester/mm/common.c
===================================================================
--- uspace/app/tester/mm/common.c	(revision 1d1bb0f43b969df62916cc6de4c6e8c2bc054416)
+++ uspace/app/tester/mm/common.c	(revision b72efe87f3e33beaa3b0d0cf7c8b598a58f6a6de)
@@ -73,10 +73,10 @@
 	link_t *link;
 	
-	while ((link = list_head(&mem_blocks)) != NULL) {
+	while ((link = list_first(&mem_blocks)) != NULL) {
 		mem_block_t *block = list_get_instance(link, mem_block_t, link);
 		free_block(block);
 	}
 	
-	while ((link = list_head(&mem_areas)) != NULL) {
+	while ((link = list_first(&mem_areas)) != NULL) {
 		mem_area_t *area = list_get_instance(link, mem_area_t, link);
 		unmap_area(area);
Index: uspace/app/usbinfo/dump.c
===================================================================
--- uspace/app/usbinfo/dump.c	(revision 1d1bb0f43b969df62916cc6de4c6e8c2bc054416)
+++ uspace/app/usbinfo/dump.c	(revision b72efe87f3e33beaa3b0d0cf7c8b598a58f6a6de)
@@ -103,8 +103,5 @@
 void dump_match_ids(match_id_list_t *matches, const char *line_prefix)
 {
-	link_t *link;
-	for (link = matches->ids.next;
-	    link != &matches->ids;
-	    link = link->next) {
+	list_foreach(matches->ids, link) {
 		match_id_t *match = list_get_instance(link, match_id_t, link);
 
Index: uspace/app/usbinfo/hid.c
===================================================================
--- uspace/app/usbinfo/hid.c	(revision 1d1bb0f43b969df62916cc6de4c6e8c2bc054416)
+++ uspace/app/usbinfo/hid.c	(revision b72efe87f3e33beaa3b0d0cf7c8b598a58f6a6de)
@@ -101,10 +101,12 @@
 	    get_indent(0), iface_no);
 	list_foreach(report->reports, report_it) {
-		usb_hid_report_description_t *description = list_get_instance(report_it, usb_hid_report_description_t, link);
+		usb_hid_report_description_t *description = list_get_instance(
+		    report_it, usb_hid_report_description_t, reports_link);
 		printf("%sReport %d (type %d)\n", get_indent(1),
 		    (int) description->report_id,
 		    (int) description->type);
 		list_foreach(description->report_items, item_it) {
-			usb_hid_report_field_t *field = list_get_instance(item_it, usb_hid_report_field_t, link);
+			usb_hid_report_field_t *field = list_get_instance(
+			    item_it, usb_hid_report_field_t, ritems_link);
 			printf("%sUsage page = 0x%04x    Usage = 0x%04x\n",
 			    get_indent(2),
Index: uspace/drv/ohci/endpoint_list.c
===================================================================
--- uspace/drv/ohci/endpoint_list.c	(revision 1d1bb0f43b969df62916cc6de4c6e8c2bc054416)
+++ uspace/drv/ohci/endpoint_list.c	(revision b72efe87f3e33beaa3b0d0cf7c8b598a58f6a6de)
@@ -103,6 +103,5 @@
 		/* There are active EDs, get the last one */
 		hcd_endpoint_t *last = list_get_instance(
-		    instance->endpoint_list.prev, hcd_endpoint_t, link);
-		assert(last);
+		    list_last(&instance->endpoint_list), hcd_endpoint_t, link);
 		last_ed = last->ed;
 	}
@@ -121,5 +120,5 @@
 
 	hcd_endpoint_t *first = list_get_instance(
-	    instance->endpoint_list.next, hcd_endpoint_t, link);
+	    list_first(&instance->endpoint_list), hcd_endpoint_t, link);
 	usb_log_debug("HCD EP(%p) added to list %s, first is %p(%p).\n",
 		hcd_ep, instance->name, first, first->ed);
@@ -153,5 +152,5 @@
 	ed_t *prev_ed;
 	/* Remove from the hardware queue */
-	if (instance->endpoint_list.next == &hcd_ep->link) {
+	if (list_first(&instance->endpoint_list) == &hcd_ep->link) {
 		/* I'm the first one here */
 		prev_ed = instance->list_head;
Index: uspace/drv/ohci/endpoint_list.h
===================================================================
--- uspace/drv/ohci/endpoint_list.h	(revision 1d1bb0f43b969df62916cc6de4c6e8c2bc054416)
+++ uspace/drv/ohci/endpoint_list.h	(revision b72efe87f3e33beaa3b0d0cf7c8b598a58f6a6de)
@@ -52,5 +52,5 @@
 	const char *name;
 	/** Sw list of all active EDs */
-	link_t endpoint_list;
+	list_t endpoint_list;
 } endpoint_list_t;
 
Index: uspace/drv/ohci/hc.c
===================================================================
--- uspace/drv/ohci/hc.c	(revision 1d1bb0f43b969df62916cc6de4c6e8c2bc054416)
+++ uspace/drv/ohci/hc.c	(revision b72efe87f3e33beaa3b0d0cf7c8b598a58f6a6de)
@@ -357,6 +357,6 @@
 		    instance->registers->periodic_current);
 
-		link_t *current = instance->pending_batches.next;
-		while (current != &instance->pending_batches) {
+		link_t *current = instance->pending_batches.head.next;
+		while (current != &instance->pending_batches.head) {
 			link_t *next = current->next;
 			usb_transfer_batch_t *batch =
@@ -367,4 +367,5 @@
 				usb_transfer_batch_finish(batch);
 			}
+
 			current = next;
 		}
Index: uspace/drv/ohci/hc.h
===================================================================
--- uspace/drv/ohci/hc.h	(revision 1d1bb0f43b969df62916cc6de4c6e8c2bc054416)
+++ uspace/drv/ohci/hc.h	(revision b72efe87f3e33beaa3b0d0cf7c8b598a58f6a6de)
@@ -68,5 +68,5 @@
 	endpoint_list_t lists[4];
 	/** List of active transfers */
-	link_t pending_batches;
+	list_t pending_batches;
 
 	/** Fibril for periodic checks if interrupts can't be used */
Index: uspace/drv/uhci/hc.c
===================================================================
--- uspace/drv/uhci/hc.c	(revision 1d1bb0f43b969df62916cc6de4c6e8c2bc054416)
+++ uspace/drv/uhci/hc.c	(revision b72efe87f3e33beaa3b0d0cf7c8b598a58f6a6de)
@@ -345,5 +345,5 @@
 
 		while (!list_empty(&done)) {
-			link_t *item = done.next;
+			link_t *item = list_first(&done);
 			list_remove(item);
 			usb_transfer_batch_t *batch =
Index: uspace/drv/uhci/transfer_list.c
===================================================================
--- uspace/drv/uhci/transfer_list.c	(revision 1d1bb0f43b969df62916cc6de4c6e8c2bc054416)
+++ uspace/drv/uhci/transfer_list.c	(revision b72efe87f3e33beaa3b0d0cf7c8b598a58f6a6de)
@@ -121,6 +121,6 @@
 	} else {
 		/* There is something scheduled */
-		usb_transfer_batch_t *last =
-		    usb_transfer_batch_from_link(instance->batch_list.prev);
+		usb_transfer_batch_t *last = usb_transfer_batch_from_link(
+		    list_last(&instance->batch_list));
 		last_qh = batch_qh(last);
 	}
@@ -146,10 +146,10 @@
 }
 /*----------------------------------------------------------------------------*/
-/** Add completed bantches to the provided list.
+/** Add completed batches to the provided list.
  *
  * @param[in] instance List to use.
  * @param[in] done list to fill
  */
-void transfer_list_remove_finished(transfer_list_t *instance, link_t *done)
+void transfer_list_remove_finished(transfer_list_t *instance, list_t *done)
 {
 	assert(instance);
@@ -157,6 +157,6 @@
 
 	fibril_mutex_lock(&instance->guard);
-	link_t *current = instance->batch_list.next;
-	while (current != &instance->batch_list) {
+	link_t *current = instance->batch_list.head.next;
+	while (current != &instance->batch_list.head) {
 		link_t * const next = current->next;
 		usb_transfer_batch_t *batch =
@@ -181,5 +181,5 @@
 	fibril_mutex_lock(&instance->guard);
 	while (!list_empty(&instance->batch_list)) {
-		link_t * const current = instance->batch_list.next;
+		link_t * const current = list_first(&instance->batch_list);
 		usb_transfer_batch_t *batch =
 		    usb_transfer_batch_from_link(current);
@@ -212,5 +212,5 @@
 	qh_t *prev_qh = NULL;
 	/* Remove from the hardware queue */
-	if (instance->batch_list.next == &batch->link) {
+	if (list_first(&instance->batch_list) == &batch->link) {
 		/* I'm the first one here */
 		prev_qh = instance->queue_head;
Index: uspace/drv/uhci/transfer_list.h
===================================================================
--- uspace/drv/uhci/transfer_list.h	(revision 1d1bb0f43b969df62916cc6de4c6e8c2bc054416)
+++ uspace/drv/uhci/transfer_list.h	(revision b72efe87f3e33beaa3b0d0cf7c8b598a58f6a6de)
@@ -51,5 +51,5 @@
 	const char *name;
 	/** List of all batches in this list */
-	link_t batch_list;
+	list_t batch_list;
 } transfer_list_t;
 
@@ -59,5 +59,5 @@
 void transfer_list_add_batch(
     transfer_list_t *instance, usb_transfer_batch_t *batch);
-void transfer_list_remove_finished(transfer_list_t *instance, link_t *done);
+void transfer_list_remove_finished(transfer_list_t *instance, list_t *done);
 void transfer_list_abort_all(transfer_list_t *instance);
 #endif
Index: uspace/drv/usbmid/explore.c
===================================================================
--- uspace/drv/usbmid/explore.c	(revision 1d1bb0f43b969df62916cc6de4c6e8c2bc054416)
+++ uspace/drv/usbmid/explore.c	(revision b72efe87f3e33beaa3b0d0cf7c8b598a58f6a6de)
@@ -54,8 +54,7 @@
  * @return Interface @p interface_no is already present in the list.
  */
-static bool interface_in_list(link_t *list, int interface_no)
+static bool interface_in_list(list_t *list, int interface_no)
 {
-	link_t *l;
-	for (l = list->next; l != list; l = l->next) {
+	list_foreach(*list, l) {
 		usbmid_interface_t *iface
 		    = list_get_instance(l, usbmid_interface_t, link);
@@ -75,5 +74,5 @@
  */
 static void create_interfaces(uint8_t *config_descriptor,
-    size_t config_descriptor_size, link_t *list)
+    size_t config_descriptor_size, list_t *list)
 {
 	usb_dp_parser_data_t data = {
@@ -181,12 +180,10 @@
 
 	/* Create interface children. */
-	link_t interface_list;
+	list_t interface_list;
 	list_initialize(&interface_list);
 	create_interfaces(config_descriptor_raw, config_descriptor_size,
 	    &interface_list);
 
-	link_t *link;
-	for (link = interface_list.next; link != &interface_list;
-	    link = link->next) {
+	list_foreach(interface_list, link) {
 		usbmid_interface_t *iface = list_get_instance(link,
 		    usbmid_interface_t, link);
Index: uspace/drv/vhc/transfer.c
===================================================================
--- uspace/drv/vhc/transfer.c	(revision 1d1bb0f43b969df62916cc6de4c6e8c2bc054416)
+++ uspace/drv/vhc/transfer.c	(revision b72efe87f3e33beaa3b0d0cf7c8b598a58f6a6de)
@@ -189,6 +189,6 @@
 	assert(!list_empty(&dev->transfer_queue));
 
-	vhc_transfer_t *transfer = list_get_instance(dev->transfer_queue.next,
-	    vhc_transfer_t, link);
+	vhc_transfer_t *transfer = list_get_instance(
+	    list_first(&dev->transfer_queue), vhc_transfer_t, link);
 	list_remove(&transfer->link);
 
Index: uspace/drv/vhc/vhcd.h
===================================================================
--- uspace/drv/vhc/vhcd.h	(revision 1d1bb0f43b969df62916cc6de4c6e8c2bc054416)
+++ uspace/drv/vhc/vhcd.h	(revision b72efe87f3e33beaa3b0d0cf7c8b598a58f6a6de)
@@ -52,10 +52,10 @@
 	usb_address_t address;
 	fibril_mutex_t guard;
-	link_t transfer_queue;
+	list_t transfer_queue;
 } vhc_virtdev_t;
 
 typedef struct {
 	uint32_t magic;
-	link_t devices;
+	list_t devices;
 	fibril_mutex_t guard;
 	usb_endpoint_manager_t ep_manager;
Index: uspace/lib/block/libblock.c
===================================================================
--- uspace/lib/block/libblock.c	(revision 1d1bb0f43b969df62916cc6de4c6e8c2bc054416)
+++ uspace/lib/block/libblock.c	(revision b72efe87f3e33beaa3b0d0cf7c8b598a58f6a6de)
@@ -60,5 +60,5 @@
 static FIBRIL_MUTEX_INITIALIZE(dcl_lock);
 /** Device connection list head. */
-static LIST_INITIALIZE(dcl_head);
+static LIST_INITIALIZE(dcl);
 
 #define CACHE_BUCKETS_LOG2  10
@@ -72,5 +72,5 @@
 	unsigned blocks_cached;   /**< Number of cached blocks. */
 	hash_table_t block_hash;
-	link_t free_head;
+	list_t free_list;
 	enum cache_mode mode;
 } cache_t;
@@ -97,9 +97,7 @@
 static devcon_t *devcon_search(devmap_handle_t devmap_handle)
 {
-	link_t *cur;
-	
 	fibril_mutex_lock(&dcl_lock);
 	
-	for (cur = dcl_head.next; cur != &dcl_head; cur = cur->next) {
+	list_foreach(dcl, cur) {
 		devcon_t *devcon = list_get_instance(cur, devcon_t, link);
 		if (devcon->devmap_handle == devmap_handle) {
@@ -116,5 +114,4 @@
     size_t bsize, void *comm_area, size_t comm_size)
 {
-	link_t *cur;
 	devcon_t *devcon;
 	
@@ -138,5 +135,5 @@
 	
 	fibril_mutex_lock(&dcl_lock);
-	for (cur = dcl_head.next; cur != &dcl_head; cur = cur->next) {
+	list_foreach(dcl, cur) {
 		devcon_t *d = list_get_instance(cur, devcon_t, link);
 		if (d->devmap_handle == devmap_handle) {
@@ -146,5 +143,5 @@
 		}
 	}
-	list_append(&devcon->link, &dcl_head);
+	list_append(&devcon->link, &dcl);
 	fibril_mutex_unlock(&dcl_lock);
 	return EOK;
@@ -294,5 +291,5 @@
 	
 	fibril_mutex_initialize(&cache->lock);
-	list_initialize(&cache->free_head);
+	list_initialize(&cache->free_list);
 	cache->lblock_size = size;
 	cache->block_count = blocks;
@@ -335,6 +332,6 @@
 	 * bother with the cache and block locks because we are single-threaded.
 	 */
-	while (!list_empty(&cache->free_head)) {
-		block_t *b = list_get_instance(cache->free_head.next,
+	while (!list_empty(&cache->free_list)) {
+		block_t *b = list_get_instance(list_first(&cache->free_list),
 		    block_t, free_link);
 
@@ -367,5 +364,5 @@
 	if (cache->blocks_cached < CACHE_LO_WATERMARK)
 		return true;
-	if (!list_empty(&cache->free_head))
+	if (!list_empty(&cache->free_list))
 		return false;
 	return true;
@@ -456,10 +453,10 @@
 			unsigned long temp_key;
 recycle:
-			if (list_empty(&cache->free_head)) {
+			if (list_empty(&cache->free_list)) {
 				fibril_mutex_unlock(&cache->lock);
 				rc = ENOMEM;
 				goto out;
 			}
-			l = cache->free_head.next;
+			l = list_first(&cache->free_list);
 			b = list_get_instance(l, block_t, free_link);
 
@@ -476,5 +473,5 @@
 				 */
 				list_remove(&b->free_link);
-				list_append(&b->free_link, &cache->free_head);
+				list_append(&b->free_link, &cache->free_list);
 				fibril_mutex_unlock(&cache->lock);
 				fibril_mutex_lock(&devcon->comm_area_lock);
@@ -668,5 +665,5 @@
 			goto retry;
 		}
-		list_append(&block->free_link, &cache->free_head);
+		list_append(&block->free_link, &cache->free_list);
 	}
 	fibril_mutex_unlock(&block->lock);
Index: uspace/lib/c/generic/adt/hash_table.c
===================================================================
--- uspace/lib/c/generic/adt/hash_table.c	(revision 1d1bb0f43b969df62916cc6de4c6e8c2bc054416)
+++ uspace/lib/c/generic/adt/hash_table.c	(revision b72efe87f3e33beaa3b0d0cf7c8b598a58f6a6de)
@@ -61,9 +61,9 @@
 	assert(max_keys > 0);
 	
-	h->entry = malloc(m * sizeof(link_t));
+	h->entry = malloc(m * sizeof(list_t));
 	if (!h->entry)
 		return false;
 	
-	memset((void *) h->entry, 0,  m * sizeof(link_t));
+	memset((void *) h->entry, 0,  m * sizeof(list_t));
 	
 	hash_count_t i;
@@ -123,7 +123,5 @@
 	assert(chain < h->entries);
 	
-	link_t *cur;
-	for (cur = h->entry[chain].next; cur != &h->entry[chain];
-	    cur = cur->next) {
+	list_foreach(h->entry[chain], cur) {
 		if (h->op->compare(key, h->max_keys, cur)) {
 			/*
@@ -153,7 +151,7 @@
 	assert(keys <= h->max_keys);
 	
-	link_t *cur;
-	
 	if (keys == h->max_keys) {
+		link_t *cur;
+		
 		/*
 		 * All keys are known, hash_table_find() can be used to find the
@@ -176,5 +174,7 @@
 	hash_index_t chain;
 	for (chain = 0; chain < h->entries; chain++) {
-		for (cur = h->entry[chain].next; cur != &h->entry[chain];
+		link_t *cur;
+		
+		for (cur = h->entry[chain].head.next; cur != &h->entry[chain].head;
 		    cur = cur->next) {
 			if (h->op->compare(key, keys, cur)) {
@@ -203,9 +203,7 @@
 {
 	hash_index_t bucket;
-	link_t *cur;
 	
 	for (bucket = 0; bucket < h->entries; bucket++) {
-		for (cur = h->entry[bucket].next; cur != &h->entry[bucket];
-		    cur = cur->next) {
+		list_foreach(h->entry[bucket], cur) {
 			f(cur, arg);
 		}
Index: uspace/lib/c/generic/adt/list.c
===================================================================
--- uspace/lib/c/generic/adt/list.c	(revision 1d1bb0f43b969df62916cc6de4c6e8c2bc054416)
+++ uspace/lib/c/generic/adt/list.c	(revision b72efe87f3e33beaa3b0d0cf7c8b598a58f6a6de)
@@ -30,29 +30,35 @@
  * @{
  */
-/** @file
+
+/**
+ * @file
+ * @brief	Functions completing doubly linked circular list implementaion.
+ *
+ * This file contains some of the functions implementing doubly linked circular lists.
+ * However, this ADT is mostly implemented in @ref list.h.
  */
 
 #include <adt/list.h>
-
+#include <bool.h>
 
 /** Check for membership
  *
- * Check whether link is contained in the list head.
- * The membership is defined as pointer equivalence.
+ * Check whether link is contained in a list.
+ * Membership is defined as pointer equivalence.
  *
- * @param link Item to look for.
- * @param head List to look in.
+ * @param link	Item to look for.
+ * @param list	List to look in.
  *
  * @return true if link is contained in head, false otherwise.
  *
  */
-int list_member(const link_t *link, const link_t *head)
+int list_member(const link_t *link, const list_t *list)
 {
-	int found = 0;
-	link_t *hlp = head->next;
+	bool found = false;
+	link_t *hlp = list->head.next;
 	
-	while (hlp != head) {
+	while (hlp != &list->head) {
 		if (hlp == link) {
-			found = 1;
+			found = true;
 			break;
 		}
@@ -63,27 +69,25 @@
 }
 
-
 /** Concatenate two lists
  *
- * Concatenate lists head1 and head2, producing a single
- * list head1 containing items from both (in head1, head2
- * order) and empty list head2.
+ * Concatenate lists @a list1 and @a list2, producing a single
+ * list @a list1 containing items from both (in @a list1, @a list2
+ * order) and empty list @a list2.
  *
- * @param head1 First list and concatenated output
- * @param head2 Second list and empty output.
+ * @param list1		First list and concatenated output
+ * @param list2 	Second list and empty output.
  *
  */
-void list_concat(link_t *head1, link_t *head2)
+void list_concat(list_t *list1, list_t *list2)
 {
-	if (list_empty(head2))
+	if (list_empty(list2))
 		return;
-	
-	head2->next->prev = head1->prev;
-	head2->prev->next = head1;
-	head1->prev->next = head2->next;
-	head1->prev = head2->prev;
-	list_initialize(head2);
+
+	list2->head.next->prev = list1->head.prev;
+	list2->head.prev->next = &list1->head;
+	list1->head.prev->next = list2->head.next;
+	list1->head.prev = list2->head.prev;
+	list_initialize(list2);
 }
-
 
 /** Count list items
@@ -91,17 +95,13 @@
  * Return the number of items in the list.
  *
- * @param link List to count.
- *
- * @return Number of items in the list.
- *
+ * @param list		List to count.
+ * @return		Number of items in the list.
  */
-unsigned int list_count(const link_t *link)
+unsigned int list_count(const list_t *list)
 {
 	unsigned int count = 0;
-	link_t *hlp = link->next;
 	
-	while (hlp != link) {
+	list_foreach(*list, link) {
 		count++;
-		hlp = hlp->next;
 	}
 	
Index: uspace/lib/c/generic/adt/prodcons.c
===================================================================
--- uspace/lib/c/generic/adt/prodcons.c	(revision 1d1bb0f43b969df62916cc6de4c6e8c2bc054416)
+++ uspace/lib/c/generic/adt/prodcons.c	(revision b72efe87f3e33beaa3b0d0cf7c8b598a58f6a6de)
@@ -61,5 +61,5 @@
 		fibril_condvar_wait(&pc->cv, &pc->mtx);
 	
-	link_t *head = pc->list.next;
+	link_t *head = list_first(&pc->list);
 	list_remove(head);
 	
Index: uspace/lib/c/generic/async.c
===================================================================
--- uspace/lib/c/generic/async.c	(revision 1d1bb0f43b969df62916cc6de4c6e8c2bc054416)
+++ uspace/lib/c/generic/async.c	(revision b72efe87f3e33beaa3b0d0cf7c8b598a58f6a6de)
@@ -160,5 +160,5 @@
 	
 	/** Messages that should be delivered to this fibril. */
-	link_t msg_queue;
+	list_t msg_queue;
 	
 	/** Identification of the opening call. */
@@ -361,6 +361,6 @@
 	wd->to_event.inlist = true;
 	
-	link_t *tmp = timeout_list.next;
-	while (tmp != &timeout_list) {
+	link_t *tmp = timeout_list.head.next;
+	while (tmp != &timeout_list.head) {
 		awaiter_t *cur
 		    = list_get_instance(tmp, awaiter_t, to_event.link);
@@ -372,5 +372,5 @@
 	}
 	
-	list_append(&wd->to_event.link, tmp);
+	list_insert_before(&wd->to_event.link, tmp);
 }
 
@@ -569,5 +569,5 @@
 	}
 	
-	msg_t *msg = list_get_instance(conn->msg_queue.next, msg_t, link);
+	msg_t *msg = list_get_instance(list_first(&conn->msg_queue), msg_t, link);
 	list_remove(&msg->link);
 	
@@ -675,6 +675,6 @@
 	while (!list_empty(&fibril_connection->msg_queue)) {
 		msg_t *msg =
-		    list_get_instance(fibril_connection->msg_queue.next, msg_t,
-		    link);
+		    list_get_instance(list_first(&fibril_connection->msg_queue),
+		    msg_t, link);
 		
 		list_remove(&msg->link);
@@ -806,6 +806,6 @@
 	futex_down(&async_futex);
 	
-	link_t *cur = timeout_list.next;
-	while (cur != &timeout_list) {
+	link_t *cur = list_first(&timeout_list);
+	while (cur != NULL) {
 		awaiter_t *waiter =
 		    list_get_instance(cur, awaiter_t, to_event.link);
@@ -813,6 +813,4 @@
 		if (tv_gt(&waiter->to_event.expires, &tv))
 			break;
-		
-		cur = cur->next;
 		
 		list_remove(&waiter->to_event.link);
@@ -828,4 +826,6 @@
 			fibril_add_ready(waiter->fid);
 		}
+		
+		cur = list_first(&timeout_list);
 	}
 	
@@ -854,6 +854,6 @@
 		suseconds_t timeout;
 		if (!list_empty(&timeout_list)) {
-			awaiter_t *waiter = list_get_instance(timeout_list.next,
-			    awaiter_t, to_event.link);
+			awaiter_t *waiter = list_get_instance(
+			    list_first(&timeout_list), awaiter_t, to_event.link);
 			
 			struct timeval tv;
@@ -1731,5 +1731,7 @@
 		 */
 		exch = (async_exch_t *)
-		    list_get_instance(sess->exch_list.next, async_exch_t, sess_link);
+		    list_get_instance(list_first(&sess->exch_list),
+		    async_exch_t, sess_link);
+		
 		list_remove(&exch->sess_link);
 		list_remove(&exch->global_link);
@@ -1743,6 +1745,6 @@
 			exch = (async_exch_t *) malloc(sizeof(async_exch_t));
 			if (exch != NULL) {
-				list_initialize(&exch->sess_link);
-				list_initialize(&exch->global_link);
+				link_initialize(&exch->sess_link);
+				link_initialize(&exch->global_link);
 				exch->sess = sess;
 				exch->phone = sess->phone;
@@ -1761,6 +1763,6 @@
 				exch = (async_exch_t *) malloc(sizeof(async_exch_t));
 				if (exch != NULL) {
-					list_initialize(&exch->sess_link);
-					list_initialize(&exch->global_link);
+					link_initialize(&exch->sess_link);
+					link_initialize(&exch->global_link);
 					exch->sess = sess;
 					exch->phone = phone;
@@ -1774,6 +1776,7 @@
 				 */
 				exch = (async_exch_t *)
-				    list_get_instance(inactive_exch_list.next, async_exch_t,
-				    global_link);
+				    list_get_instance(list_first(&inactive_exch_list),
+				    async_exch_t, global_link);
+				
 				list_remove(&exch->sess_link);
 				list_remove(&exch->global_link);
Index: uspace/lib/c/generic/devman.c
===================================================================
--- uspace/lib/c/generic/devman.c	(revision 1d1bb0f43b969df62916cc6de4c6e8c2bc054416)
+++ uspace/lib/c/generic/devman.c	(revision b72efe87f3e33beaa3b0d0cf7c8b598a58f6a6de)
@@ -35,4 +35,5 @@
  */
 
+#include <adt/list.h>
 #include <str.h>
 #include <ipc/services.h>
@@ -231,8 +232,7 @@
 	}
 	
-	link_t *link = match_ids->ids.next;
 	match_id_t *match_id = NULL;
 	
-	while (link != &match_ids->ids) {
+	list_foreach(match_ids->ids, link) {
 		match_id = list_get_instance(link, match_id_t, link);
 		
@@ -255,6 +255,4 @@
 			return retval;
 		}
-		
-		link = link->next;
 	}
 	
Index: uspace/lib/c/generic/fibril.c
===================================================================
--- uspace/lib/c/generic/fibril.c	(revision 1d1bb0f43b969df62916cc6de4c6e8c2bc054416)
+++ uspace/lib/c/generic/fibril.c	(revision b72efe87f3e33beaa3b0d0cf7c8b598a58f6a6de)
@@ -222,5 +222,6 @@
 	fibril_t *dstf;
 	if ((stype == FIBRIL_TO_MANAGER) || (stype == FIBRIL_FROM_DEAD)) {
-		dstf = list_get_instance(manager_list.next, fibril_t, link);
+		dstf = list_get_instance(list_first(&manager_list), fibril_t,
+		    link);
 		if (serialization_count && stype == FIBRIL_TO_MANAGER) {
 			serialized_threads++;
@@ -233,10 +234,10 @@
 	} else {
 		if (!list_empty(&serialized_list)) {
-			dstf = list_get_instance(serialized_list.next, fibril_t,
-			    link);
+			dstf = list_get_instance(list_first(&serialized_list),
+			    fibril_t, link);
 			serialized_threads--;
 		} else {
-			dstf = list_get_instance(ready_list.next, fibril_t,
-			    link);
+			dstf = list_get_instance(list_first(&ready_list),
+			    fibril_t, link);
 		}
 	}
@@ -326,5 +327,5 @@
 	
 	if (!list_empty(&manager_list))
-		list_remove(manager_list.next);
+		list_remove(list_first(&manager_list));
 	
 	futex_up(&fibril_futex);
Index: uspace/lib/c/generic/fibril_synch.c
===================================================================
--- uspace/lib/c/generic/fibril_synch.c	(revision 1d1bb0f43b969df62916cc6de4c6e8c2bc054416)
+++ uspace/lib/c/generic/fibril_synch.c	(revision b72efe87f3e33beaa3b0d0cf7c8b598a58f6a6de)
@@ -148,6 +148,6 @@
 		fibril_t *f;
 	
-		assert(!list_empty(&fm->waiters));
-		tmp = fm->waiters.next;
+		tmp = list_first(&fm->waiters);
+		assert(tmp != NULL);
 		wdp = list_get_instance(tmp, awaiter_t, wu_event.link);
 		wdp->active = true;
@@ -279,5 +279,5 @@
 	
 	while (!list_empty(&frw->waiters)) {
-		link_t *tmp = frw->waiters.next;
+		link_t *tmp = list_first(&frw->waiters);
 		awaiter_t *wdp;
 		fibril_t *f;
@@ -422,5 +422,5 @@
 	futex_down(&async_futex);
 	while (!list_empty(&fcv->waiters)) {
-		tmp = fcv->waiters.next;
+		tmp = list_first(&fcv->waiters);
 		wdp = list_get_instance(tmp, awaiter_t, wu_event.link);
 		list_remove(&wdp->wu_event.link);
Index: uspace/lib/c/generic/io/io.c
===================================================================
--- uspace/lib/c/generic/io/io.c	(revision 1d1bb0f43b969df62916cc6de4c6e8c2bc054416)
+++ uspace/lib/c/generic/io/io.c	(revision b72efe87f3e33beaa3b0d0cf7c8b598a58f6a6de)
@@ -127,10 +127,7 @@
 void __stdio_done(void)
 {
-	link_t *link = files.next;
-	
-	while (link != &files) {
-		FILE *file = list_get_instance(link, FILE, link);
+	while (!list_empty(&files)) {
+		FILE *file = list_get_instance(list_first(&files), FILE, link);
 		fclose(file);
-		link = files.next;
 	}
 }
Index: uspace/lib/c/generic/ipc.c
===================================================================
--- uspace/lib/c/generic/ipc.c	(revision 1d1bb0f43b969df62916cc6de4c6e8c2bc054416)
+++ uspace/lib/c/generic/ipc.c	(revision b72efe87f3e33beaa3b0d0cf7c8b598a58f6a6de)
@@ -458,5 +458,5 @@
 	while (!list_empty(&queued_calls)) {
 		async_call_t *call =
-		    list_get_instance(queued_calls.next, async_call_t, list);
+		    list_get_instance(list_first(&queued_calls), async_call_t, list);
 		ipc_callid_t callid =
 		    ipc_call_async_internal(call->u.msg.phoneid, &call->u.msg.data);
@@ -511,5 +511,5 @@
 	
 	link_t *item;
-	for (item = dispatched_calls.next; item != &dispatched_calls;
+	for (item = dispatched_calls.head.next; item != &dispatched_calls.head;
 	    item = item->next) {
 		async_call_t *call =
Index: uspace/lib/c/include/adt/hash_table.h
===================================================================
--- uspace/lib/c/include/adt/hash_table.h	(revision 1d1bb0f43b969df62916cc6de4c6e8c2bc054416)
+++ uspace/lib/c/include/adt/hash_table.h	(revision b72efe87f3e33beaa3b0d0cf7c8b598a58f6a6de)
@@ -75,5 +75,5 @@
 /** Hash table structure. */
 typedef struct {
-	link_t *entry;
+	list_t *entry;
 	hash_count_t entries;
 	hash_count_t max_keys;
Index: uspace/lib/c/include/adt/list.h
===================================================================
--- uspace/lib/c/include/adt/list.h	(revision 1d1bb0f43b969df62916cc6de4c6e8c2bc054416)
+++ uspace/lib/c/include/adt/list.h	(revision b72efe87f3e33beaa3b0d0cf7c8b598a58f6a6de)
@@ -1,4 +1,5 @@
 /*
  * Copyright (c) 2001-2004 Jakub Jermar
+ * Copyright (c) 2011 Jiri Svoboda
  * All rights reserved.
  *
@@ -36,7 +37,8 @@
 #define LIBC_LIST_H_
 
+#include <assert.h>
 #include <unistd.h>
 
-/** Doubly linked list head and link type. */
+/** Doubly linked list link. */
 typedef struct link {
 	struct link *prev;  /**< Pointer to the previous item in the list. */
@@ -44,4 +46,9 @@
 } link_t;
 
+/** Doubly linked list. */
+typedef struct list {
+	link_t head;  /**< List head. Does not have any data. */
+} list_t;
+
 /** Declare and initialize statically allocated list.
  *
@@ -50,7 +57,9 @@
  */
 #define LIST_INITIALIZE(name) \
-	link_t name = { \
-		.prev = &name, \
-		.next = &name \
+	list_t name = { \
+		.head = { \
+			.prev = &(name).head, \
+			.next = &(name).head \
+		} \
 	}
 
@@ -59,6 +68,9 @@
 
 #define list_foreach(list, iterator) \
-	for (link_t *iterator = (list).next; \
-	    iterator != &(list); iterator = iterator->next)
+	for (link_t *iterator = (list).head.next; \
+	    iterator != &(list).head; iterator = iterator->next)
+
+#define assert_link_not_used(link) \
+	assert((link)->prev == NULL && (link)->next == NULL)
 
 /** Initialize doubly-linked circular list link
@@ -79,11 +91,33 @@
  * Initialize doubly-linked circular list.
  *
- * @param list Pointer to link_t structure representing the list.
- *
- */
-static inline void list_initialize(link_t *list)
-{
-	list->prev = list;
-	list->next = list;
+ * @param list Pointer to list_t structure.
+ *
+ */
+static inline void list_initialize(list_t *list)
+{
+	list->head.prev = &list->head;
+	list->head.next = &list->head;
+}
+
+/** Insert item before another item in doubly-linked circular list.
+ *
+ */
+static inline void list_insert_before(link_t *lnew, link_t *lold)
+{
+	lnew->next = lold;
+	lnew->prev = lold->prev;
+	lold->prev->next = lnew;
+	lold->prev = lnew;
+}
+
+/** Insert item after another item in doubly-linked circular list.
+ *
+ */
+static inline void list_insert_after(link_t *lnew, link_t *lold)
+{
+	lnew->prev = lold;
+	lnew->next = lold->next;
+	lold->next->prev = lnew;
+	lold->next = lnew;
 }
 
@@ -93,13 +127,10 @@
  *
  * @param link Pointer to link_t structure to be added.
- * @param list Pointer to link_t structure representing the list.
- *
- */
-static inline void list_prepend(link_t *link, link_t *list)
-{
-	link->next = list->next;
-	link->prev = list;
-	list->next->prev = link;
-	list->next = link;
+ * @param list Pointer to list_t structure.
+ *
+ */
+static inline void list_prepend(link_t *link, list_t *list)
+{
+	list_insert_after(link, &list->head);
 }
 
@@ -109,29 +140,10 @@
  *
  * @param link Pointer to link_t structure to be added.
- * @param list Pointer to link_t structure representing the list.
- *
- */
-static inline void list_append(link_t *link, link_t *list)
-{
-	link->prev = list->prev;
-	link->next = list;
-	list->prev->next = link;
-	list->prev = link;
-}
-
-/** Insert item before another item in doubly-linked circular list.
- *
- */
-static inline void list_insert_before(link_t *link, link_t *list)
-{
-	list_append(link, list);
-}
-
-/** Insert item after another item in doubly-linked circular list.
- *
- */
-static inline void list_insert_after(link_t *link, link_t *list)
-{
-	list_prepend(list, link);
+ * @param list Pointer to list_t structure.
+ *
+ */
+static inline void list_append(link_t *link, list_t *list)
+{
+	list_insert_before(link, &list->head);
 }
 
@@ -155,15 +167,15 @@
  * Query emptiness of doubly-linked circular list.
  *
- * @param list Pointer to link_t structure representing the list.
- *
- */
-static inline int list_empty(link_t *list)
-{
-	return (list->next == list);
-}
-
-/** Get head item of a list.
- *
- * @param list Pointer to link_t structure representing the list.
+ * @param list Pointer to lins_t structure.
+ *
+ */
+static inline int list_empty(list_t *list)
+{
+	return (list->head.next == &list->head);
+}
+
+/** Get first item in list.
+ *
+ * @param list Pointer to list_t structure.
  *
  * @return Head item of the list.
@@ -171,7 +183,20 @@
  *
  */
-static inline link_t *list_head(link_t *list)
-{
-	return ((list->next == list) ? NULL : list->next);
+static inline link_t *list_first(list_t *list)
+{
+	return ((list->head.next == &list->head) ? NULL : list->head.next);
+}
+
+/** Get last item in list.
+ *
+ * @param list Pointer to list_t structure.
+ *
+ * @return Head item of the list.
+ * @return NULL if the list is empty.
+ *
+ */
+static inline link_t *list_last(list_t *list)
+{
+	return ((list->head.prev == &list->head) ? NULL : list->head.prev);
 }
 
@@ -230,5 +255,5 @@
 }
 
-/** Get n-th item of a list.
+/** Get n-th item in a list.
  *
  * @param list Pointer to link_t structure representing the list.
@@ -239,5 +264,5 @@
  *
  */
-static inline link_t *list_nth(link_t *list, unsigned int n)
+static inline link_t *list_nth(list_t *list, unsigned int n)
 {
 	unsigned int cnt = 0;
@@ -253,7 +278,7 @@
 }
 
-extern int list_member(const link_t *, const link_t *);
-extern void list_concat(link_t *, link_t *);
-extern unsigned int list_count(const link_t *);
+extern int list_member(const link_t *, const list_t *);
+extern void list_concat(list_t *, list_t *);
+extern unsigned int list_count(const list_t *);
 
 #endif
Index: uspace/lib/c/include/adt/prodcons.h
===================================================================
--- uspace/lib/c/include/adt/prodcons.h	(revision 1d1bb0f43b969df62916cc6de4c6e8c2bc054416)
+++ uspace/lib/c/include/adt/prodcons.h	(revision b72efe87f3e33beaa3b0d0cf7c8b598a58f6a6de)
@@ -42,5 +42,5 @@
 	fibril_mutex_t mtx;
 	fibril_condvar_t cv;
-	link_t list;
+	list_t list;
 } prodcons_t;
 
Index: uspace/lib/c/include/async.h
===================================================================
--- uspace/lib/c/include/async.h	(revision 1d1bb0f43b969df62916cc6de4c6e8c2bc054416)
+++ uspace/lib/c/include/async.h	(revision b72efe87f3e33beaa3b0d0cf7c8b598a58f6a6de)
@@ -99,5 +99,5 @@
 typedef struct {
 	/** List of inactive exchanges */
-	link_t exch_list;
+	list_t exch_list;
 	
 	/** Exchange management style */
Index: uspace/lib/c/include/fibril_synch.h
===================================================================
--- uspace/lib/c/include/fibril_synch.h	(revision 1d1bb0f43b969df62916cc6de4c6e8c2bc054416)
+++ uspace/lib/c/include/fibril_synch.h	(revision b72efe87f3e33beaa3b0d0cf7c8b598a58f6a6de)
@@ -45,5 +45,5 @@
 	fibril_owner_info_t oi;  /**< Keep this the first thing. */
 	int counter;
-	link_t waiters;
+	list_t waiters;
 } fibril_mutex_t;
 
@@ -55,6 +55,8 @@
 		.counter = 1, \
 		.waiters = { \
-			.prev = &name.waiters, \
-			.next = &name.waiters, \
+			.head = { \
+				.prev = &(name).waiters.head, \
+				.next = &(name).waiters.head, \
+			} \
 		} \
 	}
@@ -67,5 +69,5 @@
 	unsigned writers;
 	unsigned readers;
-	link_t waiters;
+	list_t waiters;
 } fibril_rwlock_t;
 
@@ -78,6 +80,8 @@
 		.writers = 0, \
 		.waiters = { \
-			.prev = &name.waiters, \
-			.next = &name.waiters, \
+			.head = { \
+				.prev = &(name).waiters.head, \
+				.next = &(name).waiters.head, \
+			} \
 		} \
 	}
@@ -87,5 +91,5 @@
 
 typedef struct {
-	link_t waiters;
+	list_t waiters;
 } fibril_condvar_t;
 
@@ -93,6 +97,8 @@
 	{ \
 		.waiters = { \
-			.next = &name.waiters, \
-			.prev = &name.waiters, \
+			.head = { \
+				.next = &(name).waiters.head, \
+				.prev = &(name).waiters.head, \
+			} \
 		} \
 	}
Index: uspace/lib/c/include/ipc/devman.h
===================================================================
--- uspace/lib/c/include/ipc/devman.h	(revision 1d1bb0f43b969df62916cc6de4c6e8c2bc054416)
+++ uspace/lib/c/include/ipc/devman.h	(revision b72efe87f3e33beaa3b0d0cf7c8b598a58f6a6de)
@@ -72,5 +72,5 @@
  */
 typedef struct match_id_list {
-	link_t ids;
+	list_t ids;
 } match_id_list_t;
 
@@ -95,11 +95,11 @@
 {
 	match_id_t *mid = NULL;
-	link_t *link = ids->ids.next;
+	link_t *link = ids->ids.head.next;
 	
-	while (link != &ids->ids) {
+	while (link != &ids->ids.head) {
 		mid = list_get_instance(link, match_id_t,link);
 		if (mid->score < id->score) {
 			break;
-		}	
+		}
 		link = link->next;
 	}
@@ -118,10 +118,10 @@
 	match_id_t *id;
 	
-	while(!list_empty(&ids->ids)) {
-		link = ids->ids.next;
-		list_remove(link);		
+	while (!list_empty(&ids->ids)) {
+		link = list_first(&ids->ids);
+		list_remove(link);
 		id = list_get_instance(link, match_id_t, link);
-		delete_match_id(id);		
-	}	
+		delete_match_id(id);
+	}
 }
 
Index: uspace/lib/drv/generic/driver.c
===================================================================
--- uspace/lib/drv/generic/driver.c	(revision 1d1bb0f43b969df62916cc6de4c6e8c2bc054416)
+++ uspace/lib/drv/generic/driver.c	(revision b72efe87f3e33beaa3b0d0cf7c8b598a58f6a6de)
@@ -139,10 +139,9 @@
 find_interrupt_context_by_id(interrupt_context_list_t *list, int id)
 {
+	interrupt_context_t *ctx;
+	
 	fibril_mutex_lock(&list->mutex);
 	
-	link_t *link = list->contexts.next;
-	interrupt_context_t *ctx;
-	
-	while (link != &list->contexts) {
+	list_foreach(list->contexts, link) {
 		ctx = list_get_instance(link, interrupt_context_t, link);
 		if (ctx->id == id) {
@@ -150,5 +149,4 @@
 			return ctx;
 		}
-		link = link->next;
 	}
 	
@@ -160,10 +158,9 @@
 find_interrupt_context(interrupt_context_list_t *list, ddf_dev_t *dev, int irq)
 {
+	interrupt_context_t *ctx;
+	
 	fibril_mutex_lock(&list->mutex);
 	
-	link_t *link = list->contexts.next;
-	interrupt_context_t *ctx;
-	
-	while (link != &list->contexts) {
+	list_foreach(list->contexts, link) {
 		ctx = list_get_instance(link, interrupt_context_t, link);
 		if (ctx->irq == irq && ctx->dev == dev) {
@@ -171,5 +168,4 @@
 			return ctx;
 		}
-		link = link->next;
 	}
 	
@@ -231,12 +227,11 @@
 }
 
-static ddf_fun_t *driver_get_function(link_t *functions, devman_handle_t handle)
+static ddf_fun_t *driver_get_function(list_t *functions, devman_handle_t handle)
 {
 	ddf_fun_t *fun = NULL;
 	
 	fibril_mutex_lock(&functions_mutex);
-	link_t *link = functions->next;
-	
-	while (link != functions) {
+	
+	list_foreach(*functions, link) {
 		fun = list_get_instance(link, ddf_fun_t, link);
 		if (fun->handle == handle) {
@@ -244,6 +239,4 @@
 			return fun;
 		}
-		
-		link = link->next;
 	}
 	
Index: uspace/lib/drv/include/ddf/interrupt.h
===================================================================
--- uspace/lib/drv/include/ddf/interrupt.h	(revision 1d1bb0f43b969df62916cc6de4c6e8c2bc054416)
+++ uspace/lib/drv/include/ddf/interrupt.h	(revision b72efe87f3e33beaa3b0d0cf7c8b598a58f6a6de)
@@ -60,5 +60,5 @@
 typedef struct interrupt_context_list {
 	int curr_id;
-	link_t contexts;
+	list_t contexts;
 	fibril_mutex_t mutex;
 } interrupt_context_list_t;
Index: uspace/lib/usbhid/include/usb/hid/hiddescriptor.h
===================================================================
--- uspace/lib/usbhid/include/usb/hid/hiddescriptor.h	(revision 1d1bb0f43b969df62916cc6de4c6e8c2bc054416)
+++ uspace/lib/usbhid/include/usb/hid/hiddescriptor.h	(revision b72efe87f3e33beaa3b0d0cf7c8b598a58f6a6de)
@@ -74,9 +74,9 @@
 		usb_hid_report_path_t *usage_path);
 
-void usb_hid_descriptor_print_list(link_t *head);
+void usb_hid_descriptor_print_list(list_t *list);
 
 void usb_hid_report_reset_local_items(usb_hid_report_item_t *report_item);
 
-void usb_hid_free_report_list(link_t *head);
+void usb_hid_free_report_list(list_t *list);
 
 usb_hid_report_item_t *usb_hid_report_item_clone(
Index: uspace/lib/usbhid/include/usb/hid/hidpath.h
===================================================================
--- uspace/lib/usbhid/include/usb/hid/hidpath.h	(revision 1d1bb0f43b969df62916cc6de4c6e8c2bc054416)
+++ uspace/lib/usbhid/include/usb/hid/hidpath.h	(revision b72efe87f3e33beaa3b0d0cf7c8b598a58f6a6de)
@@ -88,6 +88,6 @@
 	uint8_t flags;
 
-	/** Linked list structure*/
-	link_t link;
+	/** Link to usb_hid_report_path_t.items list */
+	link_t rpath_items_link;
 } usb_hid_report_usage_path_t;
 
@@ -98,17 +98,16 @@
  * */
 typedef struct {
-	/** Length of usage path */	
-	int depth;	
+	/** Length of usage path */
+	int depth;
 
 	/** Report id. Zero is reserved and means that report id is not used.
 	 * */
 	uint8_t report_id;
-	
-	/** Linked list structure. */	
-	link_t link; /* list */
 
-	/** Head of the list of usage path items. */
-	link_t head;
+	/** Link to usb_hid_report_path_t.collection_paths list. */
+	link_t cpath_link;
 
+	/** List of usage path items. */
+	list_t items;	/* of usb_hid_report_usage_path_t */
 } usb_hid_report_path_t;
 
Index: uspace/lib/usbhid/include/usb/hid/hidtypes.h
===================================================================
--- uspace/lib/usbhid/include/usb/hid/hidtypes.h	(revision 1d1bb0f43b969df62916cc6de4c6e8c2bc054416)
+++ uspace/lib/usbhid/include/usb/hid/hidtypes.h	(revision b72efe87f3e33beaa3b0d0cf7c8b598a58f6a6de)
@@ -95,9 +95,9 @@
 	int report_count;
 
-	/** Head of linked list of description of reports. */
-	link_t reports;
-
-	/** Head of linked list of all used usage/collection paths. */
-	link_t collection_paths;
+	/** List of description of reports. */
+	list_t reports; /* of usb_hid_report_description_t */
+
+	/** List of all used usage/collection paths. */
+	list_t collection_paths;
 
 	/** Length of list of usage paths. */
@@ -129,9 +129,9 @@
 	size_t item_length;
 	
-	/** Linked list of report items in report */
-	link_t report_items;
-
-	/** Linked list of descriptions. */
-	link_t link;
+	/** List of report items in report */
+	list_t report_items;
+
+	/** Link to usb_hid_report_t.reports list. */
+	link_t reports_link;
 } usb_hid_report_description_t;
 /*---------------------------------------------------------------------------*/
@@ -198,6 +198,6 @@
 	int32_t value;
 
-	/** List to another report items */
-	link_t link;
+	/** Link to usb_hid_report_description_t.report_items list */
+	link_t ritems_link;
 } usb_hid_report_field_t;
 
Index: uspace/lib/usbhid/src/hiddescriptor.c
===================================================================
--- uspace/lib/usbhid/src/hiddescriptor.c	(revision 1d1bb0f43b969df62916cc6de4c6e8c2bc054416)
+++ uspace/lib/usbhid/src/hiddescriptor.c	(revision b72efe87f3e33beaa3b0d0cf7c8b598a58f6a6de)
@@ -88,8 +88,8 @@
  * @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.next;
+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.head.next;
 	usb_hid_report_path_t *path = NULL;
 	
@@ -98,20 +98,20 @@
 	}
 	
-	while(path_it != &report->collection_paths) {
+	while(path_it != &report->collection_paths.head) {
 		path = list_get_instance(path_it, usb_hid_report_path_t,
-				link);
+				cpath_link);
 		
 		if(usb_hid_report_compare_usage_path(path, cmp_path,
 					USB_HID_PATH_COMPARE_STRICT) == EOK){
 			break;
-		}			
+		}
 		path_it = path_it->next;
 	}
-	if(path_it == &report->collection_paths) {
+	if(path_it == &report->collection_paths.head) {
 		path = usb_hid_report_path_clone(cmp_path);
 		if(path == NULL) {
 			return NULL;
 		}
-		list_append(&path->link, &report->collection_paths);					
+		list_append(&path->cpath_link, &report->collection_paths);
 		report->collection_paths_count++;
 
@@ -120,5 +120,5 @@
 	else {
 		return list_get_instance(path_it, usb_hid_report_path_t,
-				link); 
+				cpath_link); 
 	}
 }
@@ -192,5 +192,5 @@
 
 		memset(field, 0, sizeof(usb_hid_report_field_t));
-		list_initialize(&field->link);
+		link_initialize(&field->ritems_link);
 
 		/* fill the attributes */		
@@ -291,13 +291,13 @@
 			}
 
-			list_initialize (&report_des->link);
+			link_initialize (&report_des->reports_link);
 			list_initialize (&report_des->report_items);
 
-			list_append(&report_des->link, &report->reports);
+			list_append(&report_des->reports_link, &report->reports);
 			report->report_count++;
 		}
 
 		/* append this field to the end of founded report list */
-		list_append (&field->link, &report_des->report_items);
+		list_append(&field->ritems_link, &report_des->report_items);
 		
 		/* update the sizes */
@@ -333,10 +333,9 @@
 	}
 
-	link_t *report_it = report->reports.next;
 	usb_hid_report_description_t *report_des = NULL;
 	
-	while(report_it != &report->reports) {
+	list_foreach(report->reports, report_it) {
 		report_des = list_get_instance(report_it,
-				usb_hid_report_description_t, link);
+				usb_hid_report_description_t, reports_link);
 
 		// if report id not set, return the first of the type
@@ -345,6 +344,4 @@
 			return report_des;
 		}
-		
-		report_it = report_it->next;
 	}
 
@@ -377,7 +374,9 @@
 	size_t offset_output=0;
 	size_t offset_feature=0;
-
-	link_t stack;
-	list_initialize(&stack);	
+	
+	link_t *item_link;
+
+	list_t stack;
+	list_initialize(&stack);
 
 	/* parser structure initialization*/
@@ -391,5 +390,5 @@
 	}
 	memset(report_item, 0, sizeof(usb_hid_report_item_t));
-	list_initialize(&(report_item->link));	
+	link_initialize(&(report_item->link));
 
 	/* usage path context initialization */
@@ -493,17 +492,18 @@
 			case USB_HID_REPORT_TAG_POP:
 				// restore current state from stack
-				if(list_empty (&stack)) {
+				item_link = list_first(&stack);
+				if (item_link == NULL) {
 					return EINVAL;
 				}
 				free(report_item);
-						
-				report_item = list_get_instance(stack.next, 
+				
+				report_item = list_get_instance(item_link,
 				    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);
-					
+				    report_item->usage_path->cpath_link.prev,
+				    usb_hid_report_usage_path_t, rpath_items_link);
+				
 				usb_hid_report_set_last_item(usage_path, 
 				    USB_HID_TAG_CLASS_GLOBAL, tmp_usage_path->usage_page);
@@ -513,5 +513,5 @@
 
 				usb_hid_report_path_free(report_item->usage_path);
-				list_remove (stack.next);
+				list_remove (item_link);
 					
 				break;
@@ -609,7 +609,7 @@
 
 		/* store collection atributes */
-		path_item = list_get_instance(usage_path->head.prev, 
-			usb_hid_report_usage_path_t, link);
-		path_item->flags = *data;	
+		path_item = list_get_instance(list_first(&usage_path->items),
+			usb_hid_report_usage_path_t, rpath_items_link);
+		path_item->flags = *data;
 			
 		/* set last item */
@@ -900,35 +900,32 @@
  * @return void
  */
-void usb_hid_descriptor_print_list(link_t *head)
+void usb_hid_descriptor_print_list(list_t *list)
 {
 	usb_hid_report_field_t *report_item;
-	link_t *item;
-
-
-	if(head == NULL || list_empty(head)) {
+
+	if(list == NULL || list_empty(list)) {
 	    usb_log_debug("\tempty\n");
 	    return;
 	}
-        
-	for(item = head->next; item != head; item = item->next) {
-                
-		report_item = list_get_instance(item, usb_hid_report_field_t, 
-				link);
+
+        list_foreach(*list, item) {
+		report_item = list_get_instance(item, usb_hid_report_field_t,
+				ritems_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", 
+		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", 
+		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", 
+		usb_log_debug("\t\tUSAGES COUNT: %zu\n",
 			report_item->usages_count);
 
@@ -936,8 +933,8 @@
 		usb_log_debug("\t\ttUSAGE: %X\n", report_item->usage);
 		usb_log_debug("\t\tUSAGE PAGE: %X\n", report_item->usage_page);
-		
+
 		usb_hid_print_usage_path(report_item->collection_path);
 
-		usb_log_debug("\n");		
+		usb_log_debug("\n");
 
 	}
@@ -958,22 +955,19 @@
 	}
 
-	link_t *report_it = report->reports.next;
 	usb_hid_report_description_t *report_des;
 
-	while(report_it != &report->reports) {
-		report_des = list_get_instance(report_it, 
-			usb_hid_report_description_t, link);
+	list_foreach(report->reports, report_it) {
+		report_des = list_get_instance(report_it,
+			usb_hid_report_description_t, reports_link);
 		usb_log_debug("Report ID: %d\n", report_des->report_id);
 		usb_log_debug("\tType: %d\n", report_des->type);
-		usb_log_debug("\tLength: %zu\n", report_des->bit_length);		
+		usb_log_debug("\tLength: %zu\n", report_des->bit_length);
 		usb_log_debug("\tB Size: %zu\n",
-			usb_hid_report_byte_size(report, 
-				report_des->report_id, 
+			usb_hid_report_byte_size(report,
+				report_des->report_id,
 				report_des->type));
-		usb_log_debug("\tItems: %zu\n", report_des->item_length);		
+		usb_log_debug("\tItems: %zu\n", report_des->item_length);
 
 		usb_hid_descriptor_print_list(&report_des->report_items);
-
-		report_it = report_it->next;
 	}
 }
@@ -983,25 +977,25 @@
  * Releases whole linked list of report items
  *
- * @param head Head of list of report descriptor items (usb_hid_report_item_t)
+ * @param list List of report descriptor items (usb_hid_report_item_t)
  * @return void
  */
-void usb_hid_free_report_list(link_t *head)
+void usb_hid_free_report_list(list_t *list)
 {
-	return; 
-	
-	usb_hid_report_item_t *report_item;
+	return; /* XXX What's this? */
+	
+/*	usb_hid_report_item_t *report_item;
 	link_t *next;
 	
-	if(head == NULL || list_empty(head)) {		
+	if(list == NULL || list_empty(list)) {
 	    return;
 	}
 	
-	next = head->next;
-	while(next != head) {
-	
-	    report_item = list_get_instance(next, usb_hid_report_item_t, link);
+	next = list->head.next;
+	while (next != &list->head) {
+		report_item = list_get_instance(next, usb_hid_report_item_t,
+		    rpath_items_link);
 
 		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);
 		}
 
@@ -1013,5 +1007,5 @@
 	
 	return;
-	
+	*/
 }
 /*---------------------------------------------------------------------------*/
@@ -1029,10 +1023,13 @@
 
 	// free collection paths
+	link_t *path_link;
 	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);
-
-		usb_hid_report_path_free(path);		
+		path_link = list_first(&report->collection_paths);
+		path = list_get_instance(path_link,
+		    usb_hid_report_path_t, cpath_link);
+
+		list_remove(path_link);
+		usb_hid_report_path_free(path);
 	}
 	
@@ -1041,15 +1038,15 @@
 	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);
-
-		list_remove(&report_des->link);
+		report_des = list_get_instance(list_first(&report->reports),
+				usb_hid_report_description_t, reports_link);
+
+		list_remove(&report_des->reports_link);
 		
 		while(!list_empty(&report_des->report_items)) {
 			field = list_get_instance(
-				report_des->report_items.next, 
-				usb_hid_report_field_t, link);
-
-			list_remove(&field->link);
+			    list_first(&report_des->report_items),
+			    usb_hid_report_field_t, ritems_link);
+
+			list_remove(&field->ritems_link);
 
 			free(field);
Index: uspace/lib/usbhid/src/hidparser.c
===================================================================
--- uspace/lib/usbhid/src/hidparser.c	(revision 1d1bb0f43b969df62916cc6de4c6e8c2bc054416)
+++ uspace/lib/usbhid/src/hidparser.c	(revision b72efe87f3e33beaa3b0d0cf7c8b598a58f6a6de)
@@ -135,5 +135,4 @@
 	size_t size, uint8_t *report_id)
 {
-	link_t *list_item;
 	usb_hid_report_field_t *item;
 
@@ -161,9 +160,7 @@
 
 	/* read data */
-	list_item = report_des->report_items.next;	   
-	while(list_item != &(report_des->report_items)) {
-
+	list_foreach(report_des->report_items, list_item) {
 		item = list_get_instance(list_item, usb_hid_report_field_t, 
-				link);
+				ritems_link);
 
 		if(USB_HID_ITEM_FLAG_CONSTANT(item->item_flags) == 0) {
@@ -200,5 +197,4 @@
 			}			
 		}
-		list_item = list_item->next;
 	}
 	
@@ -310,16 +306,14 @@
 	}
 
-	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);
+
+	list_foreach(report->reports, report_it) {
+		report_des = list_get_instance(report_it,
+			usb_hid_report_description_t, reports_link);
 		
-		if((report_des->report_id == report_id) && 
+		if((report_des->report_id == report_id) &&
 			(report_des->type == USB_HID_REPORT_TYPE_OUTPUT)){
 			break;
 		}
-
-		report_it = report_it->next;
 	}
 
@@ -362,5 +356,4 @@
 	uint8_t report_id, uint8_t *buffer, size_t size)
 {
-	link_t *item;	
 	int32_t value=0;
 	int offset;
@@ -384,8 +377,9 @@
 	}
 
-	usb_hid_report_field_t *report_item;	
-	item = report_des->report_items.next;	
-	while(item != &report_des->report_items) {
-		report_item = list_get_instance(item, usb_hid_report_field_t, link);
+	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);
 
 		value = usb_hid_translate_data_reverse(report_item, 
@@ -449,6 +443,4 @@
 		// reset value
 		report_item->value = 0;
-		
-		item = item->next;
 	}
 	
@@ -550,13 +542,13 @@
 
 	if(field == NULL){
-		field_it = report_des->report_items.next;
-	}
-	else {
-		field_it = field->link.next;
-	}
-
-	while(field_it != &report_des->report_items) {
+		field_it = report_des->report_items.head.next;
+	}
+	else {
+		field_it = field->ritems_link.next;
+	}
+
+	while(field_it != &report_des->report_items.head) {
 		field = list_get_instance(field_it, usb_hid_report_field_t, 
-			link);
+			ritems_link);
 
 		if(USB_HID_ITEM_FLAG_CONSTANT(field->item_flags) == 0) {
@@ -611,14 +603,14 @@
 		}
 		else {
-			report_it = report_des->link.next;
+			report_it = report_des->reports_link.next;
 		}	
 	}
 	else {
-		report_it = report->reports.next;
-	}
-
-	while(report_it != &report->reports) {
+		report_it = report->reports.head.next;
+	}
+
+	while(report_it != &report->reports.head) {
 		report_des = list_get_instance(report_it, 
-			usb_hid_report_description_t, link);
+			usb_hid_report_description_t, reports_link);
 
 		if(report_des->type == type){
Index: uspace/lib/usbhid/src/hidpath.c
===================================================================
--- uspace/lib/usbhid/src/hidpath.c	(revision 1d1bb0f43b969df62916cc6de4c6e8c2bc054416)
+++ uspace/lib/usbhid/src/hidpath.c	(revision b72efe87f3e33beaa3b0d0cf7c8b598a58f6a6de)
@@ -81,5 +81,5 @@
 		return ENOMEM;
 	}
-	list_initialize(&item->link);
+	link_initialize(&item->rpath_items_link);
 
 	item->usage = usage;
@@ -87,5 +87,5 @@
 	item->flags = 0;
 	
-	list_append (&item->link, &usage_path->head);
+	list_append (&item->rpath_items_link, &usage_path->items);
 	usage_path->depth++;
 	return EOK;
@@ -100,10 +100,12 @@
 void usb_hid_report_remove_last_item(usb_hid_report_path_t *usage_path)
 {
+	link_t *item_link;
 	usb_hid_report_usage_path_t *item;
 	
-	if(!list_empty(&usage_path->head)){
-		item = list_get_instance(usage_path->head.prev, 
-		                         usb_hid_report_usage_path_t, link);		
-		list_remove(usage_path->head.prev);
+	if(!list_empty(&usage_path->items)){
+		item_link = list_last(&usage_path->items);
+		item = list_get_instance(item_link,
+		    usb_hid_report_usage_path_t, rpath_items_link);
+		list_remove(item_link);
 		usage_path->depth--;
 		free(item);
@@ -122,7 +124,7 @@
 	usb_hid_report_usage_path_t *item;
 	
-	if(!list_empty(&usage_path->head)){	
-		item = list_get_instance(usage_path->head.prev, 
-			usb_hid_report_usage_path_t, link);
+	if(!list_empty(&usage_path->items)){
+		item = list_get_instance(list_last(&usage_path->items),
+			usb_hid_report_usage_path_t, rpath_items_link);
 
 		memset(item, 0, sizeof(usb_hid_report_usage_path_t));
@@ -145,7 +147,7 @@
 	usb_hid_report_usage_path_t *item;
 	
-	if(!list_empty(&usage_path->head)){	
-		item = list_get_instance(usage_path->head.prev, 
-		                         usb_hid_report_usage_path_t, link);
+	if(!list_empty(&usage_path->items)){
+		item = list_get_instance(list_last(&usage_path->items),
+		     usb_hid_report_usage_path_t, rpath_items_link);
 
 		switch(tag) {
@@ -173,16 +175,13 @@
 	usb_log_debug("\tLENGTH: %d\n", path->depth);
 
-	link_t *item = path->head.next;
 	usb_hid_report_usage_path_t *path_item;
-	while(item != &path->head) {
-
-		path_item = list_get_instance(item, usb_hid_report_usage_path_t, 
-			link);
+
+	list_foreach(path->items, item) {
+		path_item = list_get_instance(item, usb_hid_report_usage_path_t,
+			rpath_items_link);
 
 		usb_log_debug("\tUSAGE_PAGE: %X\n", path_item->usage_page);
 		usb_log_debug("\tUSAGE: %X\n", path_item->usage);
-		usb_log_debug("\tFLAGS: %d\n", path_item->flags);		
-		
-       	item = item->next;
+		usb_log_debug("\tFLAGS: %d\n", path_item->flags);
 	}
 }
@@ -233,14 +232,13 @@
 		}
 
-		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);
+		path_link = list_first(&path->items);
+		path_item = list_get_instance(path_link,
+			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);
 				
-			if(USB_HID_SAME_USAGE_PAGE(report_item->usage_page, 
+			if(USB_HID_SAME_USAGE_PAGE(report_item->usage_page,
 				path_item->usage_page)){
 					
@@ -257,6 +255,4 @@
 				}
 			}
-
-			report_link = report_link->next;
 		}
 
@@ -273,15 +269,15 @@
 	case USB_HID_PATH_COMPARE_BEGIN:
 	
-		report_link = report_path->head.next;
-		path_link = path->head.next;
+		report_link = report_path->items.head.next;
+		path_link = path->items.head.next;
 			
-		while((report_link != &report_path->head) && 
-		      (path_link != &path->head)) {
+		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, link);
+				usb_hid_report_usage_path_t, rpath_items_link);
 					  
 			path_item = list_get_instance(path_link,
-       				usb_hid_report_usage_path_t, link);
+       				usb_hid_report_usage_path_t, rpath_items_link);
 
 			if(!USB_HID_SAME_USAGE_PAGE(report_item->usage_page, 
@@ -297,10 +293,10 @@
 			}
 			
-				}
+		}
 
 		if((((flags & USB_HID_PATH_COMPARE_BEGIN) != 0) && 
-			(path_link == &path->head)) || 
-		   ((report_link == &report_path->head) && 
-			(path_link == &path->head))) {
+			(path_link == &path->items.head)) || 
+		   ((report_link == &report_path->items.head) && 
+			(path_link == &path->items.head))) {
 				
 			return EOK;
@@ -314,19 +310,19 @@
 	case USB_HID_PATH_COMPARE_END:
 
-		report_link = report_path->head.prev;
-		path_link = path->head.prev;
-
-		if(list_empty(&path->head)){
+		report_link = report_path->items.head.prev;
+		path_link = path->items.head.prev;
+
+		if(list_empty(&path->items)){
 			return EOK;
 		}
 			
-		while((report_link != &report_path->head) && 
-		      (path_link != &path->head)) {
+		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, link);
+			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, link);		
+				usb_hid_report_usage_path_t, rpath_items_link);
 						  
 			if(!USB_HID_SAME_USAGE_PAGE(report_item->usage_page, 
@@ -343,5 +339,5 @@
 		}
 
-		if(path_link == &path->head) {
+		if(path_link == &path->items.head) {
 			return EOK;
 		}
@@ -373,6 +369,6 @@
 		path->depth = 0;
 		path->report_id = 0;
-		list_initialize(&path->link);
-		list_initialize(&path->head);
+		link_initialize(&path->cpath_link);
+		list_initialize(&path->items);
 		return path;
 	}
@@ -388,9 +384,9 @@
 void usb_hid_report_path_free(usb_hid_report_path_t *path)
 {
-	while(!list_empty(&path->head)){
+	while(!list_empty(&path->items)){
 		usb_hid_report_remove_last_item(path);
 	}
 
-	list_remove(&path->link);
+	assert_link_not_used(&path->cpath_link);
 	free(path);
 }
@@ -406,5 +402,4 @@
 	usb_hid_report_path_t *usage_path)
 {
-	link_t *path_link;
 	usb_hid_report_usage_path_t *path_item;
 	usb_hid_report_usage_path_t *new_path_item;
@@ -417,12 +412,11 @@
 	new_usage_path->report_id = usage_path->report_id;
 	
-	if(list_empty(&usage_path->head)){
+	if(list_empty(&usage_path->items)){
 		return new_usage_path;
 	}
 
-	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);
+	list_foreach(usage_path->items, path_link) {
+		path_item = list_get_instance(path_link,
+			usb_hid_report_usage_path_t, rpath_items_link);
 
 		new_path_item = malloc(sizeof(usb_hid_report_usage_path_t));
@@ -431,13 +425,12 @@
 		}
 		
-		list_initialize (&new_path_item->link);		
+		link_initialize(&new_path_item->rpath_items_link);
 		new_path_item->usage_page = path_item->usage_page;
 		new_path_item->usage = path_item->usage;		
 		new_path_item->flags = path_item->flags;		
 		
-		list_append(&new_path_item->link, &new_usage_path->head);
+		list_append(&new_path_item->rpath_items_link,
+		    &new_usage_path->items);
 		new_usage_path->depth++;
-
-		path_link = path_link->next;
 	}
 
Index: uspace/srv/devman/devman.c
===================================================================
--- uspace/srv/devman/devman.c	(revision 1d1bb0f43b969df62916cc6de4c6e8c2bc054416)
+++ uspace/srv/devman/devman.c	(revision b72efe87f3e33beaa3b0d0cf7c8b598a58f6a6de)
@@ -466,6 +466,5 @@
 	fibril_mutex_lock(&drivers_list->drivers_mutex);
 	
-	link_t *link = drivers_list->drivers.next;
-	while (link != &drivers_list->drivers) {
+	list_foreach(drivers_list->drivers, link) {
 		drv = list_get_instance(link, driver_t, drivers);
 		score = get_match_score(drv, node);
@@ -474,5 +473,4 @@
 			best_drv = drv;
 		}
-		link = link->next;
 	}
 	
@@ -536,10 +534,8 @@
 	driver_t *res = NULL;
 	driver_t *drv = NULL;
-	link_t *link;
 	
 	fibril_mutex_lock(&drv_list->drivers_mutex);
 	
-	link = drv_list->drivers.next;
-	while (link != &drv_list->drivers) {
+	list_foreach(drv_list->drivers, link) {
 		drv = list_get_instance(link, driver_t, drivers);
 		if (str_cmp(drv->name, drv_name) == 0) {
@@ -547,6 +543,4 @@
 			break;
 		}
-
-		link = link->next;
 	}
 	
@@ -584,6 +578,6 @@
 	 * that has not been passed to the driver.
 	 */
-	link = driver->devices.next;
-	while (link != &driver->devices) {
+	link = driver->devices.head.next;
+	while (link != &driver->devices.head) {
 		dev = list_get_instance(link, dev_node_t, driver_devices);
 		if (dev->passed_to_driver) {
@@ -622,5 +616,5 @@
 		 * Restart the cycle to go through all devices again.
 		 */
-		link = driver->devices.next;
+		link = driver->devices.head.next;
 	}
 
@@ -1187,9 +1181,6 @@
 
 	fun_node_t *fun;
-	link_t *link;
-
-	for (link = dev->functions.next;
-	    link != &dev->functions;
-	    link = link->next) {
+
+	list_foreach(dev->functions, link) {
 		fun = list_get_instance(link, fun_node_t, dev_functions);
 
@@ -1385,12 +1376,10 @@
 {
 	dev_class_t *cl;
-	link_t *link = class_list->classes.next;
-	
-	while (link != &class_list->classes) {
+	
+	list_foreach(class_list->classes, link) {
 		cl = list_get_instance(link, dev_class_t, link);
 		if (str_cmp(cl->name, class_name) == 0) {
 			return cl;
 		}
-		link = link->next;
 	}
 	
@@ -1408,8 +1397,5 @@
 	assert(dev_name != NULL);
 
-	link_t *link;
-	for (link = dev_class->devices.next;
-	    link != &dev_class->devices;
-	    link = link->next) {
+	list_foreach(dev_class->devices, link) {
 		dev_class_info_t *dev = list_get_instance(link,
 		    dev_class_info_t, link);
Index: uspace/srv/devman/devman.h
===================================================================
--- uspace/srv/devman/devman.h	(revision 1d1bb0f43b969df62916cc6de4c6e8c2bc054416)
+++ uspace/srv/devman/devman.h	(revision b72efe87f3e33beaa3b0d0cf7c8b598a58f6a6de)
@@ -96,6 +96,6 @@
 	/** List of device ids for device-to-driver matching. */
 	match_id_list_t match_ids;
-	/** Pointer to the linked list of devices controlled by this driver. */
-	link_t devices;
+	/** List of devices controlled by this driver. */
+	list_t devices;
 	
 	/**
@@ -108,5 +108,5 @@
 typedef struct driver_list {
 	/** List of drivers */
-	link_t drivers;
+	list_t drivers;
 	/** Fibril mutex for list of drivers. */
 	fibril_mutex_t drivers_mutex;
@@ -130,5 +130,5 @@
 	
 	/** List of device functions. */
-	link_t functions;
+	list_t functions;
 	/** Driver of this device. */
 	driver_t *drv;
@@ -170,6 +170,6 @@
 	match_id_list_t match_ids;
 	
-	/** The list of device classes to which this device function belongs. */
-	link_t classes;
+	/** List of device classes to which this device function belongs. */
+	list_t classes;
 	/** Devmap handle if the device function is registered by devmap. */
 	devmap_handle_t devmap_handle;
@@ -228,5 +228,5 @@
 	 * this class.
 	 */
-	link_t devices;
+	list_t devices;
 	
 	/**
@@ -280,5 +280,5 @@
 typedef struct class_list {
 	/** List of classes. */
-	link_t classes;
+	list_t classes;
 	
 	/**
Index: uspace/srv/devman/match.c
===================================================================
--- uspace/srv/devman/match.c	(revision 1d1bb0f43b969df62916cc6de4c6e8c2bc054416)
+++ uspace/srv/devman/match.c	(revision b72efe87f3e33beaa3b0d0cf7c8b598a58f6a6de)
@@ -59,9 +59,11 @@
 int get_match_score(driver_t *drv, dev_node_t *dev)
 {
-	link_t *drv_head = &drv->match_ids.ids;
-	link_t *dev_head = &dev->pfun->match_ids.ids;
+	link_t *drv_head = &drv->match_ids.ids.head;
+	link_t *dev_head = &dev->pfun->match_ids.ids.head;
 	
-	if (list_empty(drv_head) || list_empty(dev_head))
+	if (list_empty(&drv->match_ids.ids) ||
+	    list_empty(&dev->pfun->match_ids.ids)) {
 		return 0;
+	}
 	
 	/*
@@ -70,5 +72,5 @@
 	int highest_score = 0;
 	
-	link_t *drv_link = drv->match_ids.ids.next;
+	link_t *drv_link = drv->match_ids.ids.head.next;
 	while (drv_link != drv_head) {
 		link_t *dev_link = dev_head->next;
Index: uspace/srv/devmap/devmap.c
===================================================================
--- uspace/srv/devmap/devmap.c	(revision 1d1bb0f43b969df62916cc6de4c6e8c2bc054416)
+++ uspace/srv/devmap/devmap.c	(revision b72efe87f3e33beaa3b0d0cf7c8b598a58f6a6de)
@@ -57,9 +57,9 @@
  */
 typedef struct {
-	/** Pointers to previous and next drivers in linked list */
+	/** Link to drivers_list */
 	link_t drivers;
 	
-	/** Pointer to the linked list of devices controlled by this driver */
-	link_t devices;
+	/** List of devices controlled by this driver */
+	list_t devices;
 	
 	/** Session asociated with this driver */
@@ -77,5 +77,5 @@
  */
 typedef struct {
-	/** Pointer to the previous and next device in the list of all namespaces */
+	/** Link to namespaces_list */
 	link_t namespaces;
 	
@@ -94,8 +94,7 @@
  */
 typedef struct {
-	/** Pointer to the previous and next device in the list of all devices */
+	/** Link to global list of devices (devices_list) */
 	link_t devices;
-	/** Pointer to the previous and next device in the list of devices
-	    owned by one driver */
+	/** Link to driver list of devices (devmap_driver_t.devices) */
 	link_t driver_devices;
 	/** Unique device identifier */
@@ -225,9 +224,7 @@
 static devmap_namespace_t *devmap_namespace_find_name(const char *name)
 {
-	link_t *item;
-	
 	assert(fibril_mutex_is_locked(&devices_list_mutex));
 	
-	for (item = namespaces_list.next; item != &namespaces_list; item = item->next) {
+	list_foreach(namespaces_list, item) {
 		devmap_namespace_t *namespace =
 		    list_get_instance(item, devmap_namespace_t, namespaces);
@@ -246,9 +243,7 @@
 static devmap_namespace_t *devmap_namespace_find_handle(devmap_handle_t handle)
 {
-	link_t *item;
-	
 	assert(fibril_mutex_is_locked(&devices_list_mutex));
 	
-	for (item = namespaces_list.next; item != &namespaces_list; item = item->next) {
+	list_foreach(namespaces_list, item) {
 		devmap_namespace_t *namespace =
 		    list_get_instance(item, devmap_namespace_t, namespaces);
@@ -264,9 +259,7 @@
     const char *name)
 {
-	link_t *item;
-	
 	assert(fibril_mutex_is_locked(&devices_list_mutex));
 	
-	for (item = devices_list.next; item != &devices_list; item = item->next) {
+	list_foreach(devices_list, item) {
 		devmap_device_t *device =
 		    list_get_instance(item, devmap_device_t, devices);
@@ -286,9 +279,7 @@
 static devmap_device_t *devmap_device_find_handle(devmap_handle_t handle)
 {
-	link_t *item;
-	
 	assert(fibril_mutex_is_locked(&devices_list_mutex));
 	
-	for (item = devices_list.next; item != &devices_list; item = item->next) {
+	list_foreach(devices_list, item) {
 		devmap_device_t *device =
 		    list_get_instance(item, devmap_device_t, devices);
@@ -473,7 +464,8 @@
 	fibril_mutex_lock(&driver->devices_mutex);
 	
-	while (!list_empty(&(driver->devices))) {
-		devmap_device_t *device = list_get_instance(driver->devices.next,
-		    devmap_device_t, driver_devices);
+	while (!list_empty(&driver->devices)) {
+		devmap_device_t *device = list_get_instance(
+		    list_first(&driver->devices), devmap_device_t,
+		    driver_devices);
 		devmap_device_unregister_core(device);
 	}
@@ -815,8 +807,6 @@
 	}
 	
-	link_t *item;
 	size_t pos = 0;
-	for (item = namespaces_list.next; item != &namespaces_list;
-	    item = item->next) {
+	list_foreach(namespaces_list, item) {
 		devmap_namespace_t *namespace =
 		    list_get_instance(item, devmap_namespace_t, namespaces);
@@ -881,7 +871,6 @@
 	}
 	
-	link_t *item;
 	size_t pos = 0;
-	for (item = devices_list.next; item != &devices_list; item = item->next) {
+	list_foreach(devices_list, item) {
 		devmap_device_t *device =
 		    list_get_instance(item, devmap_device_t, devices);
Index: uspace/srv/fs/ext2fs/ext2fs_ops.c
===================================================================
--- uspace/srv/fs/ext2fs/ext2fs_ops.c	(revision 1d1bb0f43b969df62916cc6de4c6e8c2bc054416)
+++ uspace/srv/fs/ext2fs/ext2fs_ops.c	(revision b72efe87f3e33beaa3b0d0cf7c8b598a58f6a6de)
@@ -187,5 +187,4 @@
 {
 	EXT2FS_DBG("(%" PRIun ", -)", devmap_handle);
-	link_t *link;
 	ext2fs_instance_t *tmp;
 	
@@ -198,5 +197,5 @@
 	}
 
-	for (link = instance_list.next; link != &instance_list; link = link->next) {
+	list_foreach(instance_list, link) {
 		tmp = list_get_instance(link, ext2fs_instance_t, link);
 		
Index: uspace/srv/fs/fat/fat_idx.c
===================================================================
--- uspace/srv/fs/fat/fat_idx.c	(revision 1d1bb0f43b969df62916cc6de4c6e8c2bc054416)
+++ uspace/srv/fs/fat/fat_idx.c	(revision b72efe87f3e33beaa3b0d0cf7c8b598a58f6a6de)
@@ -67,5 +67,5 @@
 
 	/** Sorted list of intervals of freed indices. */
-	link_t		freed_head;
+	list_t		freed_list;
 } unused_t;
 
@@ -74,5 +74,5 @@
 
 /** List of unused structures. */
-static LIST_INITIALIZE(unused_head);
+static LIST_INITIALIZE(unused_list);
 
 static void unused_initialize(unused_t *u, devmap_handle_t devmap_handle)
@@ -82,5 +82,5 @@
 	u->next = 0;
 	u->remaining = ((uint64_t)((fs_index_t)-1)) + 1;
-	list_initialize(&u->freed_head);
+	list_initialize(&u->freed_list);
 }
 
@@ -88,13 +88,14 @@
 {
 	unused_t *u;
-	link_t *l;
 
 	if (lock)
 		fibril_mutex_lock(&unused_lock);
-	for (l = unused_head.next; l != &unused_head; l = l->next) {
+
+	list_foreach(unused_list, l) {
 		u = list_get_instance(l, unused_t, link);
 		if (u->devmap_handle == devmap_handle) 
 			return u;
 	}
+
 	if (lock)
 		fibril_mutex_unlock(&unused_lock);
@@ -249,5 +250,5 @@
 		return false;	
 
-	if (list_empty(&u->freed_head)) {
+	if (list_empty(&u->freed_list)) {
 		if (u->remaining) { 
 			/*
@@ -262,6 +263,6 @@
 	} else {
 		/* There are some freed indices which we can reuse. */
-		freed_t *f = list_get_instance(u->freed_head.next, freed_t,
-		    link);
+		freed_t *f = list_get_instance(list_first(&u->freed_list),
+		    freed_t, link);
 		*index = f->first;
 		if (f->first++ == f->last) {
@@ -320,10 +321,10 @@
 		link_t *lnk;
 		freed_t *n;
-		for (lnk = u->freed_head.next; lnk != &u->freed_head;
+		for (lnk = u->freed_list.head.next; lnk != &u->freed_list.head;
 		    lnk = lnk->next) {
 			freed_t *f = list_get_instance(lnk, freed_t, link);
 			if (f->first == index + 1) {
 				f->first--;
-				if (lnk->prev != &u->freed_head)
+				if (lnk->prev != &u->freed_list.head)
 					try_coalesce_intervals(lnk->prev, lnk,
 					    lnk);
@@ -333,5 +334,5 @@
 			if (f->last == index - 1) {
 				f->last++;
-				if (lnk->next != &u->freed_head)
+				if (lnk->next != &u->freed_list.head)
 					try_coalesce_intervals(lnk, lnk->next,
 					    lnk);
@@ -359,5 +360,5 @@
 		n->first = index;
 		n->last = index;
-		list_append(&n->link, &u->freed_head);
+		list_append(&n->link, &u->freed_list);
 	}
 	fibril_mutex_unlock(&unused_lock);
@@ -558,5 +559,5 @@
 	fibril_mutex_lock(&unused_lock);
 	if (!unused_find(devmap_handle, false)) {
-		list_append(&u->link, &unused_head);
+		list_append(&u->link, &unused_list);
 	} else {
 		free(u);
@@ -594,7 +595,7 @@
 	fibril_mutex_unlock(&unused_lock);
 
-	while (!list_empty(&u->freed_head)) {
+	while (!list_empty(&u->freed_list)) {
 		freed_t *f;
-		f = list_get_instance(u->freed_head.next, freed_t, link);
+		f = list_get_instance(list_first(&u->freed_list), freed_t, link);
 		list_remove(&f->link);
 		free(f);
Index: uspace/srv/fs/fat/fat_ops.c
===================================================================
--- uspace/srv/fs/fat/fat_ops.c	(revision 1d1bb0f43b969df62916cc6de4c6e8c2bc054416)
+++ uspace/srv/fs/fat/fat_ops.c	(revision b72efe87f3e33beaa3b0d0cf7c8b598a58f6a6de)
@@ -67,5 +67,5 @@
 
 /** List of cached free FAT nodes. */
-static LIST_INITIALIZE(ffn_head);
+static LIST_INITIALIZE(ffn_list);
 
 /*
@@ -147,5 +147,4 @@
 static int fat_node_fini_by_devmap_handle(devmap_handle_t devmap_handle)
 {
-	link_t *lnk;
 	fat_node_t *nodep;
 	int rc;
@@ -159,5 +158,5 @@
 restart:
 	fibril_mutex_lock(&ffn_mutex);
-	for (lnk = ffn_head.next; lnk != &ffn_head; lnk = lnk->next) {
+	list_foreach(ffn_list, lnk) {
 		nodep = list_get_instance(lnk, fat_node_t, ffn_link);
 		if (!fibril_mutex_trylock(&nodep->lock)) {
@@ -196,5 +195,5 @@
 		free(nodep);
 
-		/* Need to restart because we changed the ffn_head list. */
+		/* Need to restart because we changed ffn_list. */
 		goto restart;
 	}
@@ -211,8 +210,9 @@
 
 	fibril_mutex_lock(&ffn_mutex);
-	if (!list_empty(&ffn_head)) {
+	if (!list_empty(&ffn_list)) {
 		/* Try to use a cached free node structure. */
 		fat_idx_t *idxp_tmp;
-		nodep = list_get_instance(ffn_head.next, fat_node_t, ffn_link);
+		nodep = list_get_instance(list_first(&ffn_list), fat_node_t,
+		    ffn_link);
 		if (!fibril_mutex_trylock(&nodep->lock))
 			goto skip_cache;
@@ -473,5 +473,5 @@
 		if (nodep->idx) {
 			fibril_mutex_lock(&ffn_mutex);
-			list_append(&nodep->ffn_link, &ffn_head);
+			list_append(&nodep->ffn_link, &ffn_list);
 			fibril_mutex_unlock(&ffn_mutex);
 		} else {
Index: uspace/srv/fs/tmpfs/tmpfs.h
===================================================================
--- uspace/srv/fs/tmpfs/tmpfs.h	(revision 1d1bb0f43b969df62916cc6de4c6e8c2bc054416)
+++ uspace/srv/fs/tmpfs/tmpfs.h	(revision b72efe87f3e33beaa3b0d0cf7c8b598a58f6a6de)
@@ -67,5 +67,5 @@
 	size_t size;		/**< File size if type is TMPFS_FILE. */
 	void *data;		/**< File content's if type is TMPFS_FILE. */
-	link_t cs_head;		/**< Head of child's siblings list. */
+	list_t cs_list;		/**< Child's siblings list. */
 } tmpfs_node_t;
 
Index: uspace/srv/fs/tmpfs/tmpfs_ops.c
===================================================================
--- uspace/srv/fs/tmpfs/tmpfs_ops.c	(revision 1d1bb0f43b969df62916cc6de4c6e8c2bc054416)
+++ uspace/srv/fs/tmpfs/tmpfs_ops.c	(revision b72efe87f3e33beaa3b0d0cf7c8b598a58f6a6de)
@@ -85,5 +85,5 @@
 static int tmpfs_has_children(bool *has_children, fs_node_t *fn)
 {
-	*has_children = !list_empty(&TMPFS_NODE(fn)->cs_head);
+	*has_children = !list_empty(&TMPFS_NODE(fn)->cs_list);
 	return EOK;
 }
@@ -180,7 +180,7 @@
 	    nh_link);
 
-	while (!list_empty(&nodep->cs_head)) {
-		tmpfs_dentry_t *dentryp = list_get_instance(nodep->cs_head.next,
-		    tmpfs_dentry_t, link);
+	while (!list_empty(&nodep->cs_list)) {
+		tmpfs_dentry_t *dentryp = list_get_instance(
+		    list_first(&nodep->cs_list), tmpfs_dentry_t, link);
 
 		assert(nodep->type == TMPFS_DIRECTORY);
@@ -214,5 +214,5 @@
 	nodep->data = NULL;
 	link_initialize(&nodep->nh_link);
-	list_initialize(&nodep->cs_head);
+	list_initialize(&nodep->cs_list);
 }
 
@@ -262,8 +262,6 @@
 {
 	tmpfs_node_t *parentp = TMPFS_NODE(pfn);
-	link_t *lnk;
-
-	for (lnk = parentp->cs_head.next; lnk != &parentp->cs_head;
-	    lnk = lnk->next) {
+
+	list_foreach(parentp->cs_list, lnk) {
 		tmpfs_dentry_t *dentryp;
 		dentryp = list_get_instance(lnk, tmpfs_dentry_t, link);
@@ -353,5 +351,5 @@
 	
 	assert(!nodep->lnkcnt);
-	assert(list_empty(&nodep->cs_head));
+	assert(list_empty(&nodep->cs_list));
 
 	unsigned long key[] = {
@@ -373,11 +371,9 @@
 	tmpfs_node_t *childp = TMPFS_NODE(cfn);
 	tmpfs_dentry_t *dentryp;
-	link_t *lnk;
 
 	assert(parentp->type == TMPFS_DIRECTORY);
 
 	/* Check for duplicit entries. */
-	for (lnk = parentp->cs_head.next; lnk != &parentp->cs_head;
-	    lnk = lnk->next) {
+	list_foreach(parentp->cs_list, lnk) {
 		dentryp = list_get_instance(lnk, tmpfs_dentry_t, link);	
 		if (!str_cmp(dentryp->name, nm))
@@ -401,5 +397,5 @@
 	dentryp->node = childp;
 	childp->lnkcnt++;
-	list_append(&dentryp->link, &parentp->cs_head);
+	list_append(&dentryp->link, &parentp->cs_list);
 
 	return EOK;
@@ -411,11 +407,9 @@
 	tmpfs_node_t *childp = NULL;
 	tmpfs_dentry_t *dentryp;
-	link_t *lnk;
 
 	if (!parentp)
 		return EBUSY;
 	
-	for (lnk = parentp->cs_head.next; lnk != &parentp->cs_head;
-	    lnk = lnk->next) {
+	list_foreach(parentp->cs_list, lnk) {
 		dentryp = list_get_instance(lnk, tmpfs_dentry_t, link);
 		if (!str_cmp(dentryp->name, nm)) {
@@ -423,5 +417,5 @@
 			assert(FS_NODE(childp) == cfn);
 			break;
-		}	
+		}
 	}
 
@@ -429,5 +423,5 @@
 		return ENOENT;
 		
-	if ((childp->lnkcnt == 1) && !list_empty(&childp->cs_head))
+	if ((childp->lnkcnt == 1) && !list_empty(&childp->cs_list))
 		return ENOTEMPTY;
 
@@ -550,5 +544,4 @@
 		tmpfs_dentry_t *dentryp;
 		link_t *lnk;
-		aoff64_t i;
 		
 		assert(nodep->type == TMPFS_DIRECTORY);
@@ -559,10 +552,7 @@
 		 * hash table.
 		 */
-		for (i = 0, lnk = nodep->cs_head.next;
-		    (i < pos) && (lnk != &nodep->cs_head);
-		    i++, lnk = lnk->next)
-			;
-
-		if (lnk == &nodep->cs_head) {
+		lnk = list_nth(&nodep->cs_list, pos);
+		
+		if (lnk == NULL) {
 			async_answer_0(callid, ENOENT);
 			async_answer_1(rid, ENOENT, 0);
Index: uspace/srv/hid/input/generic/input.c
===================================================================
--- uspace/srv/hid/input/generic/input.c	(revision 1d1bb0f43b969df62916cc6de4c6e8c2bc054416)
+++ uspace/srv/hid/input/generic/input.c	(revision b72efe87f3e33beaa3b0d0cf7c8b598a58f6a6de)
@@ -75,8 +75,8 @@
 
 /** List of keyboard devices */
-static link_t kbd_devs;
+static list_t kbd_devs;
 
 /** List of mouse devices */
-link_t mouse_devs;
+list_t mouse_devs;
 
 bool irc_service = false;
Index: uspace/srv/hid/input/include/input.h
===================================================================
--- uspace/srv/hid/input/include/input.h	(revision 1d1bb0f43b969df62916cc6de4c6e8c2bc054416)
+++ uspace/srv/hid/input/include/input.h	(revision b72efe87f3e33beaa3b0d0cf7c8b598a58f6a6de)
@@ -47,5 +47,5 @@
 extern int irc_phone;
 
-extern link_t mouse_devs;
+extern list_t mouse_devs;
 
 void input_event_move(int, int);
Index: uspace/srv/hw/netif/ne2000/dp8390.c
===================================================================
--- uspace/srv/hw/netif/ne2000/dp8390.c	(revision 1d1bb0f43b969df62916cc6de4c6e8c2bc054416)
+++ uspace/srv/hw/netif/ne2000/dp8390.c	(revision b72efe87f3e33beaa3b0d0cf7c8b598a58f6a6de)
@@ -483,5 +483,5 @@
 }
 
-static link_t *ne2k_receive(ne2k_t *ne2k)
+static list_t *ne2k_receive(ne2k_t *ne2k)
 {
 	/*
@@ -490,5 +490,5 @@
 	 * frames from the network, but they will be lost.
 	 */
-	link_t *frames = (link_t *) malloc(sizeof(link_t));
+	list_t *frames = (list_t *) malloc(sizeof(list_t));
 	if (frames != NULL)
 		list_initialize(frames);
@@ -567,8 +567,8 @@
 }
 
-link_t *ne2k_interrupt(ne2k_t *ne2k, uint8_t isr, uint8_t tsr)
+list_t *ne2k_interrupt(ne2k_t *ne2k, uint8_t isr, uint8_t tsr)
 {
 	/* List of received frames */
-	link_t *frames = NULL;
+	list_t *frames = NULL;
 	
 	if (isr & (ISR_PTX | ISR_TXE)) {
Index: uspace/srv/hw/netif/ne2000/dp8390.h
===================================================================
--- uspace/srv/hw/netif/ne2000/dp8390.h	(revision 1d1bb0f43b969df62916cc6de4c6e8c2bc054416)
+++ uspace/srv/hw/netif/ne2000/dp8390.h	(revision b72efe87f3e33beaa3b0d0cf7c8b598a58f6a6de)
@@ -241,5 +241,5 @@
 extern void ne2k_down(ne2k_t *);
 extern void ne2k_send(ne2k_t *, packet_t *);
-extern link_t *ne2k_interrupt(ne2k_t *, uint8_t, uint8_t);
+extern list_t *ne2k_interrupt(ne2k_t *, uint8_t, uint8_t);
 
 #endif
Index: uspace/srv/hw/netif/ne2000/ne2000.c
===================================================================
--- uspace/srv/hw/netif/ne2000/ne2000.c	(revision 1d1bb0f43b969df62916cc6de4c6e8c2bc054416)
+++ uspace/srv/hw/netif/ne2000/ne2000.c	(revision b72efe87f3e33beaa3b0d0cf7c8b598a58f6a6de)
@@ -168,15 +168,15 @@
 	
 	if (ne2k != NULL) {
-		link_t *frames =
+		list_t *frames =
 		    ne2k_interrupt(ne2k, IRQ_GET_ISR(*call), IRQ_GET_TSR(*call));
 		
 		if (frames != NULL) {
 			while (!list_empty(frames)) {
-				frame_t *frame =
-				    list_get_instance(frames->next, frame_t, link);
+				frame_t *frame = list_get_instance(
+				    list_first(frames), frame_t, link);
 				
 				list_remove(&frame->link);
-				nil_received_msg(nil_phone, device_id, frame->packet,
-				    SERVICE_NONE);
+				nil_received_msg(nil_phone, device_id,
+				    frame->packet, SERVICE_NONE);
 				free(frame);
 			}
Index: uspace/srv/ns/clonable.c
===================================================================
--- uspace/srv/ns/clonable.c	(revision 1d1bb0f43b969df62916cc6de4c6e8c2bc054416)
+++ uspace/srv/ns/clonable.c	(revision b72efe87f3e33beaa3b0d0cf7c8b598a58f6a6de)
@@ -52,5 +52,5 @@
 
 /** List of clonable-service connection requests. */
-static link_t cs_req;
+static list_t cs_req;
 
 int clonable_init(void)
@@ -76,5 +76,8 @@
     ipc_callid_t callid)
 {
-	if (list_empty(&cs_req)) {
+	link_t *req_link;
+
+	req_link = list_first(&cs_req);
+	if (req_link == NULL) {
 		/* There was no pending connection request. */
 		printf("%s: Unexpected clonable server.\n", NAME);
@@ -83,6 +86,6 @@
 	}
 	
-	cs_req_t *csr = list_get_instance(cs_req.next, cs_req_t, link);
-	list_remove(&csr->link);
+	cs_req_t *csr = list_get_instance(req_link, cs_req_t, link);
+	list_remove(req_link);
 	
 	/* Currently we can only handle a single type of clonable service. */
Index: uspace/srv/ns/service.c
===================================================================
--- uspace/srv/ns/service.c	(revision 1d1bb0f43b969df62916cc6de4c6e8c2bc054416)
+++ uspace/srv/ns/service.c	(revision b72efe87f3e33beaa3b0d0cf7c8b598a58f6a6de)
@@ -123,5 +123,5 @@
 } pending_conn_t;
 
-static link_t pending_conn;
+static list_t pending_conn;
 
 int service_init(void)
@@ -141,8 +141,6 @@
 void process_pending_conn(void)
 {
-	link_t *cur;
-	
 loop:
-	for (cur = pending_conn.next; cur != &pending_conn; cur = cur->next) {
+	list_foreach(pending_conn, cur) {
 		pending_conn_t *pr = list_get_instance(cur, pending_conn_t, link);
 		
Index: uspace/srv/ns/task.c
===================================================================
--- uspace/srv/ns/task.c	(revision 1d1bb0f43b969df62916cc6de4c6e8c2bc054416)
+++ uspace/srv/ns/task.c	(revision b72efe87f3e33beaa3b0d0cf7c8b598a58f6a6de)
@@ -189,5 +189,5 @@
 } pending_wait_t;
 
-static link_t pending_wait;
+static list_t pending_wait;
 
 int task_init(void)
@@ -212,9 +212,8 @@
 void process_pending_wait(void)
 {
-	link_t *cur;
 	task_exit_t texit;
 	
 loop:
-	for (cur = pending_wait.next; cur != &pending_wait; cur = cur->next) {
+	list_foreach(pending_wait, cur) {
 		pending_wait_t *pr = list_get_instance(cur, pending_wait_t, link);
 		
Index: uspace/srv/vfs/vfs.h
===================================================================
--- uspace/srv/vfs/vfs.h	(revision 1d1bb0f43b969df62916cc6de4c6e8c2bc054416)
+++ uspace/srv/vfs/vfs.h	(revision b72efe87f3e33beaa3b0d0cf7c8b598a58f6a6de)
@@ -145,7 +145,7 @@
 extern fibril_mutex_t nodes_mutex;
 
-extern fibril_condvar_t fs_head_cv;
-extern fibril_mutex_t fs_head_lock;
-extern link_t fs_head;		/**< List of registered file systems. */
+extern fibril_condvar_t fs_list_cv;
+extern fibril_mutex_t fs_list_lock;
+extern list_t fs_list;		/**< List of registered file systems. */
 
 extern vfs_pair_t rootfs;	/**< Root file system. */
@@ -158,7 +158,7 @@
 } plb_entry_t;
 
-extern fibril_mutex_t plb_mutex;/**< Mutex protecting plb and plb_head. */
+extern fibril_mutex_t plb_mutex;/**< Mutex protecting plb and plb_entries. */
 extern uint8_t *plb;		/**< Path Lookup Buffer */
-extern link_t plb_head;		/**< List of active PLB entries. */
+extern list_t plb_entries;	/**< List of active PLB entries. */
 
 #define MAX_MNTOPTS_LEN		256
Index: uspace/srv/vfs/vfs_lookup.c
===================================================================
--- uspace/srv/vfs/vfs_lookup.c	(revision 1d1bb0f43b969df62916cc6de4c6e8c2bc054416)
+++ uspace/srv/vfs/vfs_lookup.c	(revision b72efe87f3e33beaa3b0d0cf7c8b598a58f6a6de)
@@ -50,5 +50,5 @@
 
 FIBRIL_MUTEX_INITIALIZE(plb_mutex);
-LIST_INITIALIZE(plb_head);	/**< PLB entry ring buffer. */
+LIST_INITIALIZE(plb_entries);	/**< PLB entry ring buffer. */
 uint8_t *plb = NULL;
 
@@ -102,12 +102,12 @@
 	size_t last;	/* the last free index */
 
-	if (list_empty(&plb_head)) {
+	if (list_empty(&plb_entries)) {
 		first = 0;
 		last = PLB_SIZE - 1;
 	} else {
-		plb_entry_t *oldest = list_get_instance(plb_head.next,
-		    plb_entry_t, plb_link);
-		plb_entry_t *newest = list_get_instance(plb_head.prev,
-		    plb_entry_t, plb_link);
+		plb_entry_t *oldest = list_get_instance(
+		    list_first(&plb_entries), plb_entry_t, plb_link);
+		plb_entry_t *newest = list_get_instance(
+		    list_last(&plb_entries), plb_entry_t, plb_link);
 
 		first = (newest->index + newest->len) % PLB_SIZE;
@@ -145,5 +145,5 @@
 	 * buffer.
 	 */
-	list_append(&entry.plb_link, &plb_head);
+	list_append(&entry.plb_link, &plb_entries);
 	
 	fibril_mutex_unlock(&plb_mutex);
Index: uspace/srv/vfs/vfs_ops.c
===================================================================
--- uspace/srv/vfs/vfs_ops.c	(revision 1d1bb0f43b969df62916cc6de4c6e8c2bc054416)
+++ uspace/srv/vfs/vfs_ops.c	(revision b72efe87f3e33beaa3b0d0cf7c8b598a58f6a6de)
@@ -325,5 +325,5 @@
 	 * This will also give us its file system handle.
 	 */
-	fibril_mutex_lock(&fs_head_lock);
+	fibril_mutex_lock(&fs_list_lock);
 	fs_handle_t fs_handle;
 recheck:
@@ -331,9 +331,9 @@
 	if (!fs_handle) {
 		if (flags & IPC_FLAG_BLOCKING) {
-			fibril_condvar_wait(&fs_head_cv, &fs_head_lock);
+			fibril_condvar_wait(&fs_list_cv, &fs_list_lock);
 			goto recheck;
 		}
 		
-		fibril_mutex_unlock(&fs_head_lock);
+		fibril_mutex_unlock(&fs_list_lock);
 		async_answer_0(callid, ENOENT);
 		async_answer_0(rid, ENOENT);
@@ -343,5 +343,5 @@
 		return;
 	}
-	fibril_mutex_unlock(&fs_head_lock);
+	fibril_mutex_unlock(&fs_list_lock);
 	
 	/* Acknowledge that we know fs_name. */
Index: uspace/srv/vfs/vfs_register.c
===================================================================
--- uspace/srv/vfs/vfs_register.c	(revision 1d1bb0f43b969df62916cc6de4c6e8c2bc054416)
+++ uspace/srv/vfs/vfs_register.c	(revision b72efe87f3e33beaa3b0d0cf7c8b598a58f6a6de)
@@ -52,7 +52,7 @@
 #include "vfs.h"
 
-FIBRIL_CONDVAR_INITIALIZE(fs_head_cv);
-FIBRIL_MUTEX_INITIALIZE(fs_head_lock);
-LIST_INITIALIZE(fs_head);
+FIBRIL_CONDVAR_INITIALIZE(fs_list_cv);
+FIBRIL_MUTEX_INITIALIZE(fs_list_lock);
+LIST_INITIALIZE(fs_list);
 
 atomic_t fs_handle_next = {
@@ -149,5 +149,5 @@
 	}
 	
-	fibril_mutex_lock(&fs_head_lock);
+	fibril_mutex_lock(&fs_list_lock);
 	
 	/*
@@ -159,5 +159,5 @@
 		 */
 		dprintf("FS is already registered.\n");
-		fibril_mutex_unlock(&fs_head_lock);
+		fibril_mutex_unlock(&fs_list_lock);
 		free(fs_info);
 		async_answer_0(rid, EEXISTS);
@@ -169,5 +169,5 @@
 	 */
 	dprintf("Inserting FS into the list of registered file systems.\n");
-	list_append(&fs_info->fs_link, &fs_head);
+	list_append(&fs_info->fs_link, &fs_list);
 	
 	/*
@@ -180,5 +180,5 @@
 		dprintf("Callback connection expected\n");
 		list_remove(&fs_info->fs_link);
-		fibril_mutex_unlock(&fs_head_lock);
+		fibril_mutex_unlock(&fs_list_lock);
 		free(fs_info);
 		async_answer_0(rid, EINVAL);
@@ -197,5 +197,5 @@
 		dprintf("Unexpected call, method = %d\n", IPC_GET_IMETHOD(call));
 		list_remove(&fs_info->fs_link);
-		fibril_mutex_unlock(&fs_head_lock);
+		fibril_mutex_unlock(&fs_list_lock);
 		async_hangup(fs_info->sess);
 		free(fs_info);
@@ -211,5 +211,5 @@
 		dprintf("Client suggests wrong size of PFB, size = %d\n", size);
 		list_remove(&fs_info->fs_link);
-		fibril_mutex_unlock(&fs_head_lock);
+		fibril_mutex_unlock(&fs_list_lock);
 		async_hangup(fs_info->sess);
 		free(fs_info);
@@ -235,6 +235,6 @@
 	async_answer_1(rid, EOK, (sysarg_t) fs_info->fs_handle);
 	
-	fibril_condvar_broadcast(&fs_head_cv);
-	fibril_mutex_unlock(&fs_head_lock);
+	fibril_condvar_broadcast(&fs_list_cv);
+	fibril_mutex_unlock(&fs_list_lock);
 	
 	dprintf("\"%.*s\" filesystem successfully registered, handle=%d.\n",
@@ -254,15 +254,14 @@
 	/*
 	 * For now, we don't try to be very clever and very fast.
-	 * We simply lookup the session in the fs_head list and
+	 * We simply lookup the session in fs_list and
 	 * begin an exchange.
 	 */
-	fibril_mutex_lock(&fs_head_lock);
-	
-	link_t *cur;
-	for (cur = fs_head.next; cur != &fs_head; cur = cur->next) {
+	fibril_mutex_lock(&fs_list_lock);
+	
+	list_foreach(fs_list, cur) {
 		fs_info_t *fs = list_get_instance(cur, fs_info_t, fs_link);
 		
 		if (fs->fs_handle == handle) {
-			fibril_mutex_unlock(&fs_head_lock);
+			fibril_mutex_unlock(&fs_list_lock);
 			
 			assert(fs->sess);
@@ -274,5 +273,5 @@
 	}
 	
-	fibril_mutex_unlock(&fs_head_lock);
+	fibril_mutex_unlock(&fs_list_lock);
 	
 	return NULL;
@@ -293,5 +292,5 @@
  * @param name File system name.
  * @param lock If true, the function will lock and unlock the
- *             fs_head_lock.
+ *             fs_list_lock.
  *
  * @return File system handle or zero if file system not found.
@@ -303,8 +302,7 @@
 	
 	if (lock)
-		fibril_mutex_lock(&fs_head_lock);
-	
-	link_t *cur;
-	for (cur = fs_head.next; cur != &fs_head; cur = cur->next) {
+		fibril_mutex_lock(&fs_list_lock);
+	
+	list_foreach(fs_list, cur) {
 		fs_info_t *fs = list_get_instance(cur, fs_info_t, fs_link);
 		if (str_cmp(fs->vfs_info.name, name) == 0) { 
@@ -315,5 +313,5 @@
 	
 	if (lock)
-		fibril_mutex_unlock(&fs_head_lock);
+		fibril_mutex_unlock(&fs_list_lock);
 	
 	return handle;
@@ -330,8 +328,7 @@
 {
 	vfs_info_t *info = NULL;
-	link_t *cur;
-	
-	fibril_mutex_lock(&fs_head_lock);
-	for (cur = fs_head.next; cur != &fs_head; cur = cur->next) {
+	
+	fibril_mutex_lock(&fs_list_lock);
+	list_foreach(fs_list, cur) {
 		fs_info_t *fs = list_get_instance(cur, fs_info_t, fs_link);
 		if (fs->fs_handle == handle) { 
@@ -340,5 +337,5 @@
 		}
 	}
-	fibril_mutex_unlock(&fs_head_lock);
+	fibril_mutex_unlock(&fs_list_lock);
 	
 	return info;
