Index: uspace/lib/packet/generic/packet_server.c
===================================================================
--- uspace/lib/packet/generic/packet_server.c	(revision 0485135c4340bfe39246c5097af24c53043005de)
+++ uspace/lib/packet/generic/packet_server.c	(revision 0b81cad0360a509d54d5a8a7f64c14e5fb6f91e6)
@@ -212,5 +212,6 @@
 	
 	for (index = 0; index < FREE_QUEUES_COUNT; index++) {
-		if (length > ps_globals.sizes[index])
+		if ((length > ps_globals.sizes[index]) &&
+		    (index < FREE_QUEUES_COUNT - 1))
 			continue;
 		
Index: uspace/srv/net/il/arp/arp.c
===================================================================
--- uspace/srv/net/il/arp/arp.c	(revision 0485135c4340bfe39246c5097af24c53043005de)
+++ uspace/srv/net/il/arp/arp.c	(revision 0b81cad0360a509d54d5a8a7f64c14e5fb6f91e6)
@@ -55,5 +55,5 @@
 #include <ipc/il.h>
 #include <byteorder.h>
-#include <err.h>
+#include <errno.h>
 
 #include <net/modules.h>
@@ -179,16 +179,20 @@
     measured_string_ref address)
 {
-	ERROR_DECLARE;
+	int rc;
 
 	*proto = (arp_proto_ref) malloc(sizeof(arp_proto_t));
 	if (!*proto)
 		return ENOMEM;
+	
 	(*proto)->service = service;
 	(*proto)->addr = address;
 	(*proto)->addr_data = address->value;
-	if (ERROR_OCCURRED(arp_addr_initialize(&(*proto)->addresses))) {
+	
+	rc = arp_addr_initialize(&(*proto)->addresses);
+	if (rc != EOK) {
 		free(*proto);
-		return ERROR_CODE;
-	}
+		return rc;
+	}
+	
 	return EOK;
 }
@@ -214,10 +218,9 @@
     services_t protocol, measured_string_ref address)
 {
-	ERROR_DECLARE;
-
 	arp_device_ref device;
 	arp_proto_ref proto;
+	hw_type_t hardware;
 	int index;
-	hw_type_t hardware;
+	int rc;
 
 	fibril_rwlock_write_lock(&arp_globals.lock);
@@ -237,8 +240,8 @@
 			proto->addr_data = address->value;
 		} else {
-			if (ERROR_OCCURRED(arp_proto_create(&proto, protocol,
-			    address))) {
+			rc = arp_proto_create(&proto, protocol, address);
+			if (rc != EOK) {
 				fibril_rwlock_write_unlock(&arp_globals.lock);
-				return ERROR_CODE;
+				return rc;
 			}
 			index = arp_protos_add(&device->protos, proto->service,
@@ -265,10 +268,15 @@
 		device->hardware = hardware;
 		device->device_id = device_id;
-		if (ERROR_OCCURRED(arp_protos_initialize(&device->protos)) ||
-		    ERROR_OCCURRED(arp_proto_create(&proto, protocol,
-		    address))) {
+		rc = arp_protos_initialize(&device->protos);
+		if (rc != EOK) {
 			fibril_rwlock_write_unlock(&arp_globals.lock);
 			free(device);
-			return ERROR_CODE;
+			return rc;
+		}
+		rc = arp_proto_create(&proto, protocol, address);
+		if (rc != EOK) {
+			fibril_rwlock_write_unlock(&arp_globals.lock);
+			free(device);
+			return rc;
 		}
 		index = arp_protos_add(&device->protos, proto->service, proto);
@@ -293,25 +301,27 @@
 		
 		// get packet dimensions
-		if (ERROR_OCCURRED(nil_packet_size_req(device->phone, device_id,
-		    &device->packet_dimension))) {
+		rc = nil_packet_size_req(device->phone, device_id,
+		    &device->packet_dimension);
+		if (rc != EOK) {
 			fibril_rwlock_write_unlock(&arp_globals.lock);
 			arp_protos_destroy(&device->protos);
 			free(device);
-			return ERROR_CODE;
+			return rc;
 		}
 		
 		// get hardware address
-		if (ERROR_OCCURRED(nil_get_addr_req(device->phone, device_id,
-		    &device->addr, &device->addr_data))) {
+		rc = nil_get_addr_req(device->phone, device_id, &device->addr,
+		    &device->addr_data);
+		if (rc != EOK) {
 			fibril_rwlock_write_unlock(&arp_globals.lock);
 			arp_protos_destroy(&device->protos);
 			free(device);
-			return ERROR_CODE;
+			return rc;
 		}
 		
 		// get broadcast address
-		if (ERROR_OCCURRED(nil_get_broadcast_addr_req(device->phone,
-		    device_id, &device->broadcast_addr,
-		    &device->broadcast_data))) {
+		rc = nil_get_broadcast_addr_req(device->phone, device_id,
+		    &device->broadcast_addr, &device->broadcast_data);
+		if (rc != EOK) {
 			fibril_rwlock_write_unlock(&arp_globals.lock);
 			free(device->addr);
@@ -319,9 +329,10 @@
 			arp_protos_destroy(&device->protos);
 			free(device);
-			return ERROR_CODE;
-		}
-		
-		if (ERROR_OCCURRED(arp_cache_add(&arp_globals.cache,
-		    device->device_id, device))) {
+			return rc;
+		}
+		
+		rc = arp_cache_add(&arp_globals.cache, device->device_id,
+		    device);
+		if (rc != EOK) {
 			fibril_rwlock_write_unlock(&arp_globals.lock);
 			free(device->addr);
@@ -331,5 +342,5 @@
 			arp_protos_destroy(&device->protos);
 			free(device);
-			return ERROR_CODE;
+			return rc;
 		}
 		printf("%s: Device registered (id: %d, type: 0x%x, service: %d,"
@@ -351,12 +362,13 @@
 int arp_initialize(async_client_conn_t client_connection)
 {
-	ERROR_DECLARE;
+	int rc;
 
 	fibril_rwlock_initialize(&arp_globals.lock);
 	fibril_rwlock_write_lock(&arp_globals.lock);
 	arp_globals.client_connection = client_connection;
-	ERROR_PROPAGATE(arp_cache_initialize(&arp_globals.cache));
+	rc = arp_cache_initialize(&arp_globals.cache);
 	fibril_rwlock_write_unlock(&arp_globals.lock);
-	return EOK;
+	
+	return rc;
 }
 
@@ -406,6 +418,4 @@
 static int arp_receive_message(device_id_t device_id, packet_t packet)
 {
-	ERROR_DECLARE;
-
 	size_t length;
 	arp_header_ref header;
@@ -417,4 +427,5 @@
 	uint8_t *des_hw;
 	uint8_t *des_proto;
+	int rc;
 
 	length = packet_get_data_length(packet);
@@ -467,7 +478,9 @@
 				return ENOMEM;
 
-			ERROR_PROPAGATE(arp_addr_add(&proto->addresses,
-			    (char *) src_proto, CONVERT_SIZE(uint8_t, char,
-			    header->protocol_length), hw_source));
+			rc = arp_addr_add(&proto->addresses, (char *) src_proto,
+			    CONVERT_SIZE(uint8_t, char,
+			    header->protocol_length), hw_source);
+			if (rc != EOK)
+				return rc;
 		}
 		if (ntohs(header->operation) == ARPOP_REQUEST) {
@@ -480,6 +493,10 @@
 			memcpy(des_hw, hw_source->value,
 			    header->hardware_length);
-			ERROR_PROPAGATE(packet_set_addr(packet, src_hw, des_hw,
-			    header->hardware_length));
+			
+			rc = packet_set_addr(packet, src_hw, des_hw,
+			    header->hardware_length);
+			if (rc != EOK)
+				return rc;
+			
 			nil_send_msg(device->phone, device_id, packet,
 			    SERVICE_ARP);
@@ -596,6 +613,4 @@
     ipc_call_t *answer, int *answer_count)
 {
-	ERROR_DECLARE;
-	
 	measured_string_ref address;
 	measured_string_ref translation;
@@ -603,4 +618,5 @@
 	packet_t packet;
 	packet_t next;
+	int rc;
 	
 	*answer_count = 0;
@@ -610,14 +626,21 @@
 	
 	case NET_ARP_DEVICE:
-		ERROR_PROPAGATE(measured_strings_receive(&address, &data, 1));
-		if (ERROR_OCCURRED(arp_device_message(IPC_GET_DEVICE(call),
-		    IPC_GET_SERVICE(call), ARP_GET_NETIF(call), address))) {
+		rc = measured_strings_receive(&address, &data, 1);
+		if (rc != EOK)
+			return rc;
+		
+		rc = arp_device_message(IPC_GET_DEVICE(call),
+		    IPC_GET_SERVICE(call), ARP_GET_NETIF(call), address);
+		if (rc != EOK) {
 			free(address);
 			free(data);
 		}
-		return ERROR_CODE;
+		return rc;
 	
 	case NET_ARP_TRANSLATE:
-		ERROR_PROPAGATE(measured_strings_receive(&address, &data, 1));
+		rc = measured_strings_receive(&address, &data, 1);
+		if (rc != EOK)
+			return rc;
+		
 		fibril_rwlock_read_lock(&arp_globals.lock);
 		translation = arp_translate_message(IPC_GET_DEVICE(call),
@@ -629,7 +652,7 @@
 			return ENOENT;
 		}
-		ERROR_CODE = measured_strings_reply(translation, 1);
+		rc = measured_strings_reply(translation, 1);
 		fibril_rwlock_read_unlock(&arp_globals.lock);
-		return ERROR_CODE;
+		return rc;
 
 	case NET_ARP_CLEAR_DEVICE:
@@ -637,5 +660,8 @@
 
 	case NET_ARP_CLEAR_ADDRESS:
-		ERROR_PROPAGATE(measured_strings_receive(&address, &data, 1));
+		rc = measured_strings_receive(&address, &data, 1);
+		if (rc != EOK)
+			return rc;
+		
 		arp_clear_address_req(0, IPC_GET_DEVICE(call),
 		    IPC_GET_SERVICE(call), address);
@@ -652,21 +678,22 @@
 	
 	case NET_IL_RECEIVED:
-		if (ERROR_NONE(packet_translate_remote(arp_globals.net_phone,
-		    &packet, IPC_GET_PACKET(call)))) {
-			fibril_rwlock_read_lock(&arp_globals.lock);
-			do {
-				next = pq_detach(packet);
-				ERROR_CODE =
-				    arp_receive_message(IPC_GET_DEVICE(call),
-				    packet);
-				if (ERROR_CODE != 1) {
-					pq_release_remote(arp_globals.net_phone,
-					    packet_get_id(packet));
-				}
-				packet = next;
-			} while (packet);
-			fibril_rwlock_read_unlock(&arp_globals.lock);
-		}
-		return ERROR_CODE;
+		rc = packet_translate_remote(arp_globals.net_phone, &packet,
+		    IPC_GET_PACKET(call));
+		if (rc != EOK)
+			return rc;
+		
+		fibril_rwlock_read_lock(&arp_globals.lock);
+		do {
+			next = pq_detach(packet);
+			rc = arp_receive_message(IPC_GET_DEVICE(call), packet);
+			if (rc != 1) {
+				pq_release_remote(arp_globals.net_phone,
+				    packet_get_id(packet));
+			}
+			packet = next;
+		} while (packet);
+		fibril_rwlock_read_unlock(&arp_globals.lock);
+		
+		return EOK;
 	
 	case NET_IL_MTU_CHANGED:
@@ -727,9 +754,9 @@
 int main(int argc, char *argv[])
 {
-	ERROR_DECLARE;
+	int rc;
 	
 	/* Start the module */
-	ERROR_PROPAGATE(il_module_start_standalone(il_client_connection));
-	return EOK;
+	rc = il_module_start_standalone(il_client_connection);
+	return rc;
 }
 
Index: uspace/srv/net/il/arp/arp_module.c
===================================================================
--- uspace/srv/net/il/arp/arp_module.c	(revision 0485135c4340bfe39246c5097af24c53043005de)
+++ uspace/srv/net/il/arp/arp_module.c	(revision 0b81cad0360a509d54d5a8a7f64c14e5fb6f91e6)
@@ -41,5 +41,5 @@
 #include <async.h>
 #include <stdio.h>
-#include <err.h>
+#include <errno.h>
 
 #include <ipc/ipc.h>
@@ -66,21 +66,27 @@
 int il_module_start_standalone(async_client_conn_t client_connection)
 {
-	ERROR_DECLARE;
+	ipcarg_t phonehash;
+	int rc;
 	
 	async_set_client_connection(client_connection);
 	arp_globals.net_phone = net_connect_module();
-	ERROR_PROPAGATE(pm_init());
 	
-	ipcarg_t phonehash;
-	if (ERROR_OCCURRED(arp_initialize(client_connection)) ||
-	    ERROR_OCCURRED(REGISTER_ME(SERVICE_ARP, &phonehash))) {
-		pm_destroy();
-		return ERROR_CODE;
-	}
+	rc = pm_init();
+	if (rc != EOK)
+		return rc;
+	
+	rc = arp_initialize(client_connection);
+	if (rc != EOK)
+		goto out;
+	
+	rc = REGISTER_ME(SERVICE_ARP, &phonehash);
+	if (rc != EOK)
+		goto out;
 	
 	async_manager();
-	
+
+out:
 	pm_destroy();
-	return EOK;
+	return rc;
 }
 
Index: uspace/srv/net/il/ip/ip.c
===================================================================
--- uspace/srv/net/il/ip/ip.c	(revision 0485135c4340bfe39246c5097af24c53043005de)
+++ uspace/srv/net/il/ip/ip.c	(revision 0b81cad0360a509d54d5a8a7f64c14e5fb6f91e6)
@@ -41,5 +41,4 @@
 #include <async.h>
 #include <errno.h>
-#include <err.h>
 #include <fibril_synch.h>
 #include <stdio.h>
@@ -254,5 +253,5 @@
 int ip_initialize(async_client_conn_t client_connection)
 {
-	ERROR_DECLARE;
+	int rc;
 
 	fibril_rwlock_initialize(&ip_globals.lock);
@@ -265,13 +264,22 @@
 	ip_globals.gateway.gateway.s_addr = 0;
 	ip_globals.gateway.netif = NULL;
-	ERROR_PROPAGATE(ip_netifs_initialize(&ip_globals.netifs));
-	ERROR_PROPAGATE(ip_protos_initialize(&ip_globals.protos));
 	ip_globals.client_connection = client_connection;
-	ERROR_PROPAGATE(modules_initialize(&ip_globals.modules));
-	ERROR_PROPAGATE(add_module(NULL, &ip_globals.modules, ARP_NAME,
-	    ARP_FILENAME, SERVICE_ARP, 0, arp_connect_module));
+	
+	rc = ip_netifs_initialize(&ip_globals.netifs);
+	if (rc != EOK)
+		goto out;
+	rc = ip_protos_initialize(&ip_globals.protos);
+	if (rc != EOK)
+		goto out;
+	rc = modules_initialize(&ip_globals.modules);
+	if (rc != EOK)
+		goto out;
+	rc = add_module(NULL, &ip_globals.modules, ARP_NAME, ARP_FILENAME,
+	    SERVICE_ARP, 0, arp_connect_module);
+
+out:
 	fibril_rwlock_write_unlock(&ip_globals.lock);
 
-	return EOK;
+	return rc;
 }
 
@@ -302,6 +310,4 @@
 static int ip_netif_initialize(ip_netif_ref ip_netif)
 {
-	ERROR_DECLARE;
-
 	measured_string_t names[] = {
 		{
@@ -342,7 +348,8 @@
 	char *data;
 	measured_string_t address;
-	int index;
 	ip_route_ref route;
 	in_addr_t gateway;
+	int index;
+	int rc;
 
 	ip_netif->arp = NULL;
@@ -354,6 +361,9 @@
 
 	// get configuration
-	ERROR_PROPAGATE(net_get_device_conf_req(ip_globals.net_phone,
-	    ip_netif->device_id, &configuration, count, &data));
+	rc = net_get_device_conf_req(ip_globals.net_phone, ip_netif->device_id,
+	    &configuration, count, &data);
+	if (rc != EOK)
+		return rc;
+	
 	if (configuration) {
 		if (configuration[0].value)
@@ -383,10 +393,9 @@
 				return index;
 			}
-			if (ERROR_OCCURRED(inet_pton(AF_INET,
-			    configuration[2].value,
-			    (uint8_t *) &route->address.s_addr)) ||
-			    ERROR_OCCURRED(inet_pton(AF_INET,
-			    configuration[3].value,
-			    (uint8_t *) &route->netmask.s_addr)) ||
+			
+			if ((inet_pton(AF_INET, configuration[2].value,
+			    (uint8_t *) &route->address.s_addr) != EOK) ||
+			    (inet_pton(AF_INET, configuration[3].value,
+			    (uint8_t *) &route->netmask.s_addr) != EOK) ||
 			    (inet_pton(AF_INET, configuration[4].value,
 			    (uint8_t *) &gateway.s_addr) == EINVAL) ||
@@ -434,7 +443,10 @@
 			address.value = (char *) &route->address.s_addr;
 			address.length = CONVERT_SIZE(in_addr_t, char, 1);
-			ERROR_PROPAGATE(arp_device_req(ip_netif->arp->phone,
+			
+			rc = arp_device_req(ip_netif->arp->phone,
 			    ip_netif->device_id, SERVICE_IP, ip_netif->service,
-			    &address));
+			    &address);
+			if (rc != EOK)
+				return rc;
 		} else {
 			ip_netif->arp = 0;
@@ -443,6 +455,9 @@
 
 	// get packet dimensions
-	ERROR_PROPAGATE(nil_packet_size_req(ip_netif->phone,
-	    ip_netif->device_id, &ip_netif->packet_dimension));
+	rc = nil_packet_size_req(ip_netif->phone, ip_netif->device_id,
+	    &ip_netif->packet_dimension);
+	if (rc != EOK)
+		return rc;
+	
 	if (ip_netif->packet_dimension.content < IP_MIN_CONTENT) {
 		printf("Maximum transmission unit %d bytes is too small, at "
@@ -610,6 +625,4 @@
     measured_string_ref destination)
 {
-	ERROR_DECLARE;
-
 	size_t length;
 	ip_header_ref header;
@@ -617,4 +630,5 @@
 	ip_header_ref middle_header;
 	packet_t next;
+	int rc;
 
 	length = packet_get_data_length(packet);
@@ -624,10 +638,12 @@
 	header = (ip_header_ref) packet_get_data(packet);
 	if (destination) {
-		ERROR_PROPAGATE(packet_set_addr(packet, NULL,
-		    (uint8_t *) destination->value,
-		    CONVERT_SIZE(char, uint8_t, destination->length)));
+		rc = packet_set_addr(packet, NULL, (uint8_t *) destination->value,
+		    CONVERT_SIZE(char, uint8_t, destination->length));
 	} else {
-		ERROR_PROPAGATE(packet_set_addr(packet, NULL, NULL, 0));
-	}
+		rc = packet_set_addr(packet, NULL, NULL, 0);
+	}
+	if (rc != EOK)
+		return rc;
+	
 	header->version = IPV4;
 	header->fragment_offset_high = 0;
@@ -669,10 +685,11 @@
 			    IP_HEADER_CHECKSUM(middle_header);
 			if (destination) {
-				if (ERROR_OCCURRED(packet_set_addr(next, NULL,
+				rc = packet_set_addr(next, NULL,
 				    (uint8_t *) destination->value,
 				    CONVERT_SIZE(char, uint8_t,
-				    destination->length)))) {
+				    destination->length));
+				if (rc != EOK) {
 				    	free(last_header);
-					return ERROR_CODE;
+					return rc;
 				}
 			}
@@ -699,11 +716,11 @@
 		    IP_HEADER_CHECKSUM(middle_header);
 		if (destination) {
-			if (ERROR_OCCURRED(packet_set_addr(next, NULL,
+			rc = packet_set_addr(next, NULL,
 			    (uint8_t *) destination->value,
-			    CONVERT_SIZE(char, uint8_t,
-			    destination->length)))) {
+			    CONVERT_SIZE(char, uint8_t, destination->length));
+			if (rc != EOK) {
 				free(last_header);
-				return ERROR_CODE;
-			    }
+				return rc;
+			}
 		}
 		length += packet_get_data_length(next);
@@ -741,8 +758,7 @@
     const struct sockaddr *src, const struct sockaddr *dest, socklen_t addrlen)
 {
-	ERROR_DECLARE;
-
 	void *data;
 	size_t offset;
+	int rc;
 
 	data = packet_suffix(new_packet, length);
@@ -752,5 +768,9 @@
 	memcpy(data, ((void *) header) + IP_TOTAL_LENGTH(header) - length,
 	    length);
-	ERROR_PROPAGATE(packet_trim(packet, 0, length));
+	
+	rc = packet_trim(packet, 0, length);
+	if (rc != EOK)
+		return rc;
+	
 	header->total_length = htons(IP_TOTAL_LENGTH(header) - length);
 	new_header->total_length = htons(IP_HEADER_LENGTH(new_header) + length);
@@ -761,6 +781,9 @@
 	    IP_COMPUTE_FRAGMENT_OFFSET_LOW(offset);
 	new_header->header_checksum = IP_HEADER_CHECKSUM(new_header);
-	ERROR_PROPAGATE(packet_set_addr(new_packet, (const uint8_t *) src,
-	    (const uint8_t *) dest, addrlen));
+	
+	rc = packet_set_addr(new_packet, (const uint8_t *) src,
+	    (const uint8_t *) dest, addrlen);
+	if (rc != EOK)
+		return rc;
 
 	return pq_insert_after(packet, new_packet);
@@ -796,6 +819,4 @@
     socklen_t addr_len)
 {
-	ERROR_DECLARE;
-
 	packet_t new_packet;
 	ip_header_ref header;
@@ -806,4 +827,5 @@
 	socklen_t addrlen;
 	int result;
+	int rc;
 
 	result = packet_get_addr(packet, (uint8_t **) &src, (uint8_t **) &dest);
@@ -839,20 +861,20 @@
 
 	// trim the unused space
-	if (ERROR_OCCURRED(packet_trim(new_packet, 0,
-	    IP_HEADER_LENGTH(header) - IP_HEADER_LENGTH(last_header)))) {
-		return ip_release_and_return(packet, ERROR_CODE);
-	}
+	rc = packet_trim(new_packet, 0,
+	    IP_HEADER_LENGTH(header) - IP_HEADER_LENGTH(last_header));
+	if (rc != EOK)
+		return ip_release_and_return(packet, rc);
 
 	// biggest multiple of 8 lower than content
 	// TODO even fragmentation?
 	length = length & ~0x7;
-	if (ERROR_OCCURRED(ip_fragment_packet_data(packet, new_packet, header,
-	    last_header,
+	
+	rc = ip_fragment_packet_data(packet, new_packet, header, last_header,
 	    ((IP_HEADER_DATA_LENGTH(header) -
 	    ((length - IP_HEADER_LENGTH(header)) & ~0x7)) %
-	    ((length - IP_HEADER_LENGTH(last_header)) & ~0x7)), src, dest,
-	    addrlen))) {
-		return ip_release_and_return(packet, ERROR_CODE);
-	}
+	    ((length - IP_HEADER_LENGTH(last_header)) & ~0x7)),
+	    src, dest, addrlen);
+	if (rc != EOK)
+		return ip_release_and_return(packet, rc);
 
 	// mark the first as fragmented
@@ -872,10 +894,10 @@
 			return ip_release_and_return(packet, ENOMEM);
 
-		if (ERROR_OCCURRED(ip_fragment_packet_data(packet, new_packet,
-		    header, middle_header,
-		    (length - IP_HEADER_LENGTH(middle_header)) & ~0x7, src,
-		    dest, addrlen))) {
-			return ip_release_and_return(packet, ERROR_CODE);
-		}
+		rc = ip_fragment_packet_data(packet, new_packet, header,
+		    middle_header,
+		    (length - IP_HEADER_LENGTH(middle_header)) & ~0x7,
+		    src, dest, addrlen);
+		if (rc != EOK)
+			return ip_release_and_return(packet, rc);
 	}
 
@@ -974,10 +996,9 @@
     in_addr_t *src, in_addr_t dest, services_t error)
 {
-	ERROR_DECLARE;
-
 	measured_string_t destination;
 	measured_string_ref translation;
 	char *data;
 	int phone;
+	int rc;
 
 	// get destination hardware address
@@ -987,10 +1008,10 @@
 		destination.length = CONVERT_SIZE(dest.s_addr, char, 1);
 
-		if (ERROR_OCCURRED(arp_translate_req(netif->arp->phone,
-		    netif->device_id, SERVICE_IP, &destination, &translation,
-		    &data))) {
+		rc = arp_translate_req(netif->arp->phone, netif->device_id,
+		    SERVICE_IP, &destination, &translation, &data);
+		if (rc != EOK) {
 			pq_release_remote(ip_globals.net_phone,
 			    packet_get_id(packet));
-			return ERROR_CODE;
+			return rc;
 		}
 
@@ -1014,5 +1035,6 @@
 	}
 
-	if (ERROR_OCCURRED(ip_prepare_packet(src, dest, packet, translation))) {
+	rc = ip_prepare_packet(src, dest, packet, translation);
+	if (rc != EOK) {
 		pq_release_remote(ip_globals.net_phone, packet_get_id(packet));
 	} else {
@@ -1032,5 +1054,5 @@
 	}
 
-	return ERROR_CODE;
+	return rc;
 }
 
@@ -1158,9 +1180,8 @@
 ip_device_req_local(int il_phone, device_id_t device_id, services_t netif)
 {
-	ERROR_DECLARE;
-
 	ip_netif_ref ip_netif;
 	ip_route_ref route;
 	int index;
+	int rc;
 
 	ip_netif = (ip_netif_ref) malloc(sizeof(ip_netif_t));
@@ -1168,7 +1189,8 @@
 		return ENOMEM;
 
-	if (ERROR_OCCURRED(ip_routes_initialize(&ip_netif->routes))) {
+	rc = ip_routes_initialize(&ip_netif->routes);
+	if (rc != EOK) {
 		free(ip_netif);
-		return ERROR_CODE;
+		return rc;
 	}
 
@@ -1178,9 +1200,11 @@
 
 	fibril_rwlock_write_lock(&ip_globals.netifs_lock);
-	if (ERROR_OCCURRED(ip_netif_initialize(ip_netif))) {
+
+	rc = ip_netif_initialize(ip_netif);
+	if (rc != EOK) {
 		fibril_rwlock_write_unlock(&ip_globals.netifs_lock);
 		ip_routes_destroy(&ip_netif->routes);
 		free(ip_netif);
-		return ERROR_CODE;
+		return rc;
 	}
 	if (ip_netif->arp)
@@ -1226,6 +1250,4 @@
     services_t sender, services_t error)
 {
-	ERROR_DECLARE;
-
 	int addrlen;
 	ip_netif_ref netif;
@@ -1236,4 +1258,5 @@
 	in_addr_t *src;
 	int phone;
+	int rc;
 
 	// addresses in the host byte order
@@ -1323,8 +1346,8 @@
 	}
 
-	ERROR_CODE = ip_send_route(packet, netif, route, src, *dest, error);
+	rc = ip_send_route(packet, netif, route, src, *dest, error);
 	fibril_rwlock_read_unlock(&ip_globals.netifs_lock);
 
-	return ERROR_CODE;
+	return rc;
 }
 
@@ -1431,6 +1454,4 @@
     services_t error)
 {
-	ERROR_DECLARE;
-
 	ip_proto_ref proto;
 	int phone;
@@ -1442,4 +1463,5 @@
 	struct sockaddr_in dest_in;
 	socklen_t addrlen;
+	int rc;
 
 	if ((header->flags & IPFLAG_MORE_FRAGMENTS) ||
@@ -1467,15 +1489,16 @@
 	}
 
-	if (ERROR_OCCURRED(packet_set_addr(packet, (uint8_t *) src,
-	    (uint8_t *) dest, addrlen))) {
-		return ip_release_and_return(packet, ERROR_CODE);
-	}
+	rc = packet_set_addr(packet, (uint8_t *) src, (uint8_t *) dest,
+	    addrlen);
+	if (rc != EOK)
+		return ip_release_and_return(packet, rc);
 
 	// trim padding if present
 	if (!error &&
 	    (IP_TOTAL_LENGTH(header) < packet_get_data_length(packet))) {
-		if (ERROR_OCCURRED(packet_trim(packet, 0,
-		    packet_get_data_length(packet) - IP_TOTAL_LENGTH(header))))
-			return ip_release_and_return(packet, ERROR_CODE);
+		rc = packet_trim(packet, 0,
+		    packet_get_data_length(packet) - IP_TOTAL_LENGTH(header));
+		if (rc != EOK)
+			return ip_release_and_return(packet, rc);
 	}
 
@@ -1498,12 +1521,12 @@
 		received_msg = proto->received_msg;
 		fibril_rwlock_read_unlock(&ip_globals.protos_lock);
-		ERROR_CODE = received_msg(device_id, packet, service, error);
+		rc = received_msg(device_id, packet, service, error);
 	} else {
-		ERROR_CODE = tl_received_msg(proto->phone, device_id, packet,
+		rc = tl_received_msg(proto->phone, device_id, packet,
 		    proto->service, error);
 		fibril_rwlock_read_unlock(&ip_globals.protos_lock);
 	}
 
-	return ERROR_CODE;
+	return rc;
 }
 
@@ -1532,6 +1555,4 @@
 ip_process_packet(device_id_t device_id, packet_t packet)
 {
-	ERROR_DECLARE;
-
 	ip_header_ref header;
 	in_addr_t dest;
@@ -1541,4 +1562,5 @@
 	struct sockaddr_in addr_in;
 	socklen_t addrlen;
+	int rc;
 
 	header = (ip_header_ref) packet_get_data(packet);
@@ -1585,6 +1607,7 @@
 	}
 
-	ERROR_PROPAGATE(packet_set_addr(packet, NULL, (uint8_t *) &addr,
-	    addrlen));
+	rc = packet_set_addr(packet, NULL, (uint8_t *) &addr, addrlen);
+	if (rc != EOK)
+		return rc;
 
 	route = ip_find_route(dest);
@@ -1867,6 +1890,4 @@
     int *answer_count)
 {
-	ERROR_DECLARE;
-	
 	packet_t packet;
 	struct sockaddr *addr;
@@ -1878,4 +1899,5 @@
 	size_t headerlen;
 	device_id_t device_id;
+	int rc;
 	
 	*answer_count = 0;
@@ -1893,6 +1915,8 @@
 	
 	case NET_IL_SEND:
-		ERROR_PROPAGATE(packet_translate_remote(ip_globals.net_phone,
-		    &packet, IPC_GET_PACKET(call)));
+		rc = packet_translate_remote(ip_globals.net_phone, &packet,
+		    IPC_GET_PACKET(call));
+		if (rc != EOK)
+			return rc;
 		return ip_send_msg_local(0, IPC_GET_DEVICE(call), packet, 0,
 		    IPC_GET_ERROR(call));
@@ -1903,11 +1927,15 @@
 	
 	case NET_IL_RECEIVED:
-		ERROR_PROPAGATE(packet_translate_remote(ip_globals.net_phone,
-		    &packet, IPC_GET_PACKET(call)));
+		rc = packet_translate_remote(ip_globals.net_phone, &packet,
+		    IPC_GET_PACKET(call));
+		if (rc != EOK)
+			return rc;
 		return ip_receive_message(IPC_GET_DEVICE(call), packet);
 	
 	case NET_IP_RECEIVED_ERROR:
-		ERROR_PROPAGATE(packet_translate_remote(ip_globals.net_phone,
-		    &packet, IPC_GET_PACKET(call)));
+		rc = packet_translate_remote(ip_globals.net_phone, &packet,
+		    IPC_GET_PACKET(call));
+		if (rc != EOK)
+			return rc;
 		return ip_received_error_msg_local(0, IPC_GET_DEVICE(call),
 		    packet, IPC_GET_TARGET(call), IPC_GET_ERROR(call));
@@ -1923,22 +1951,31 @@
 
 	case NET_IP_GET_ROUTE:
-		ERROR_PROPAGATE(data_receive((void **) &addr, &addrlen));
-		ERROR_PROPAGATE(ip_get_route_req_local(0, IP_GET_PROTOCOL(call),
-		    addr, (socklen_t) addrlen, &device_id, &header,
-		    &headerlen));
+		rc = data_receive((void **) &addr, &addrlen);
+		if (rc != EOK)
+			return rc;
+		
+		rc = ip_get_route_req_local(0, IP_GET_PROTOCOL(call), addr,
+		    (socklen_t) addrlen, &device_id, &header, &headerlen);
+		if (rc != EOK)
+			return rc;
+		
 		IPC_SET_DEVICE(answer, device_id);
 		IP_SET_HEADERLEN(answer, headerlen);
 		
 		*answer_count = 2;
-			
-		if (ERROR_NONE(data_reply(&headerlen, sizeof(headerlen))))
-			ERROR_CODE = data_reply(header, headerlen);
+		
+		rc = data_reply(&headerlen, sizeof(headerlen));
+		if (rc == EOK)
+			rc = data_reply(header, headerlen);
 			
 		free(header);
-		return ERROR_CODE;
+		return rc;
 	
 	case NET_IL_PACKET_SPACE:
-		ERROR_PROPAGATE(ip_packet_size_message(IPC_GET_DEVICE(call),
-		    &addrlen, &prefix, &content, &suffix));
+		rc = ip_packet_size_message(IPC_GET_DEVICE(call), &addrlen,
+		    &prefix, &content, &suffix);
+		if (rc != EOK)
+			return rc;
+		
 		IPC_SET_ADDR(answer, addrlen);
 		IPC_SET_PREFIX(answer, prefix);
@@ -2005,9 +2042,9 @@
 int main(int argc, char *argv[])
 {
-	ERROR_DECLARE;
+	int rc;
 	
 	/* Start the module */
-	ERROR_PROPAGATE(il_module_start_standalone(il_client_connection));
-	return EOK;
+	rc = il_module_start_standalone(il_client_connection);
+	return rc;
 }
 
Index: uspace/srv/net/il/ip/ip_module.c
===================================================================
--- uspace/srv/net/il/ip/ip_module.c	(revision 0485135c4340bfe39246c5097af24c53043005de)
+++ uspace/srv/net/il/ip/ip_module.c	(revision 0b81cad0360a509d54d5a8a7f64c14e5fb6f91e6)
@@ -44,5 +44,5 @@
 #include <ipc/ipc.h>
 #include <ipc/services.h>
-#include <err.h>
+#include <errno.h>
 
 #include <net/modules.h>
@@ -66,21 +66,27 @@
 int il_module_start_standalone(async_client_conn_t client_connection)
 {
-	ERROR_DECLARE;
+	ipcarg_t phonehash;
+	int rc;
 	
 	async_set_client_connection(client_connection);
 	ip_globals.net_phone = net_connect_module();
-	ERROR_PROPAGATE(pm_init());
+
+	rc = pm_init();
+	if (rc != EOK)
+		return rc;
 	
-	ipcarg_t phonehash;
-	if (ERROR_OCCURRED(ip_initialize(client_connection)) ||
-	    ERROR_OCCURRED(REGISTER_ME(SERVICE_IP, &phonehash))) {
-		pm_destroy();
-		return ERROR_CODE;
-	}
+	rc = ip_initialize(client_connection);
+	if (rc != EOK)
+		goto out;
+	
+	rc = REGISTER_ME(SERVICE_IP, &phonehash);
+	if (rc != EOK)
+		goto out;
 	
 	async_manager();
-	
+
+out:
 	pm_destroy();
-	return EOK;
+	return rc;
 }
 
Index: uspace/srv/net/netif/lo/lo.c
===================================================================
--- uspace/srv/net/netif/lo/lo.c	(revision 0485135c4340bfe39246c5097af24c53043005de)
+++ uspace/srv/net/netif/lo/lo.c	(revision 0b81cad0360a509d54d5a8a7f64c14e5fb6f91e6)
@@ -37,5 +37,4 @@
 #include <async.h>
 #include <errno.h>
-#include <err.h>
 #include <stdio.h>
 #include <str.h>
@@ -83,11 +82,12 @@
 int netif_get_device_stats(device_id_t device_id, device_stats_ref stats)
 {
-	ERROR_DECLARE;
-
 	netif_device_t *device;
+	int rc;
 
 	if (!stats)
 		return EBADMEM;
-	ERROR_PROPAGATE(find_device(device_id, &device));
+	rc = find_device(device_id, &device);
+	if (rc != EOK)
+		return rc;
 	memcpy(stats, (device_stats_ref) device->specific,
 	    sizeof(device_stats_t));
@@ -164,10 +164,11 @@
 int netif_probe_message(device_id_t device_id, int irq, uintptr_t io)
 {
-	ERROR_DECLARE;
-
 	netif_device_t *device;
+	int rc;
 
 	// create a new device
-	ERROR_PROPAGATE(create(device_id, &device));
+	rc = create(device_id, &device);
+	if (rc != EOK)
+		return rc;
 	// print the settings
 	printf("%s: Device created (id: %d)\n", NAME, device->device_id);
@@ -177,12 +178,13 @@
 int netif_send_message(device_id_t device_id, packet_t packet, services_t sender)
 {
-	ERROR_DECLARE;
-
 	netif_device_t *device;
 	size_t length;
 	packet_t next;
 	int phone;
-
-	ERROR_PROPAGATE(find_device(device_id, &device));
+	int rc;
+
+	rc = find_device(device_id, &device);
+	if (rc != EOK)
+		return EOK;
 	if (device->state != NETIF_ACTIVE) {
 		netif_pq_release(packet_get_id(packet));
@@ -259,9 +261,9 @@
 int main(int argc, char *argv[])
 {
-	ERROR_DECLARE;
+	int rc;
 	
 	/* Start the module */
-	ERROR_PROPAGATE(netif_module_start(netif_client_connection));
-	return EOK;
+	rc = netif_module_start(netif_client_connection);
+	return rc;
 }
 
Index: uspace/srv/net/nil/eth/eth.c
===================================================================
--- uspace/srv/net/nil/eth/eth.c	(revision 0485135c4340bfe39246c5097af24c53043005de)
+++ uspace/srv/net/nil/eth/eth.c	(revision 0b81cad0360a509d54d5a8a7f64c14e5fb6f91e6)
@@ -42,5 +42,5 @@
 #include <byteorder.h>
 #include <str.h>
-#include <err.h>
+#include <errno.h>
 
 #include <ipc/ipc.h>
@@ -196,5 +196,5 @@
 int nil_initialize(int net_phone)
 {
-	ERROR_DECLARE;
+	int rc;
 
 	fibril_rwlock_initialize(&eth_globals.devices_lock);
@@ -208,12 +208,14 @@
 	    CONVERT_SIZE(uint8_t, char, ETH_ADDR));
 	if (!eth_globals.broadcast_addr) {
-		ERROR_CODE = ENOMEM;
+		rc = ENOMEM;
 		goto out;
 	}
-	if (ERROR_OCCURRED(eth_devices_initialize(&eth_globals.devices))) {
+	rc = eth_devices_initialize(&eth_globals.devices);
+	if (rc != EOK) {
 		free(eth_globals.broadcast_addr);
 		goto out;
 	}
-	if (ERROR_OCCURRED(eth_protos_initialize(&eth_globals.protos))) {
+	rc = eth_protos_initialize(&eth_globals.protos);
+	if (rc != EOK) {
 		free(eth_globals.broadcast_addr);
 		eth_devices_destroy(&eth_globals.devices);
@@ -223,5 +225,5 @@
 	fibril_rwlock_write_unlock(&eth_globals.devices_lock);
 	
-	return ERROR_CODE;
+	return rc;
 }
 
@@ -234,7 +236,6 @@
 static void eth_receiver(ipc_callid_t iid, ipc_call_t *icall)
 {
-	ERROR_DECLARE;
-
 	packet_t packet;
+	int rc;
 
 	while (true) {
@@ -246,11 +247,11 @@
 			break;
 		case NET_NIL_RECEIVED:
-			if (ERROR_NONE(packet_translate_remote(
-			    eth_globals.net_phone, &packet,
-			    IPC_GET_PACKET(icall)))) {
-				ERROR_CODE = nil_received_msg_local(0,
+			rc = packet_translate_remote(eth_globals.net_phone,
+			    &packet, IPC_GET_PACKET(icall));
+			if (rc == EOK) {
+				rc = nil_received_msg_local(0,
 				    IPC_GET_DEVICE(icall), packet, 0);
 			}
-			ipc_answer_0(iid, (ipcarg_t) ERROR_CODE);
+			ipc_answer_0(iid, (ipcarg_t) rc);
 			break;
 		default:
@@ -282,6 +283,4 @@
 eth_device_message(device_id_t device_id, services_t service, size_t mtu)
 {
-	ERROR_DECLARE;
-
 	eth_device_ref device;
 	int index;
@@ -300,4 +299,5 @@
 	char *data;
 	eth_proto_ref proto;
+	int rc;
 
 	fibril_rwlock_write_lock(&eth_globals.devices_lock);
@@ -351,9 +351,10 @@
 
 	configuration = &names[0];
-	if (ERROR_OCCURRED(net_get_device_conf_req(eth_globals.net_phone,
-	    device->device_id, &configuration, count, &data))) {
+	rc = net_get_device_conf_req(eth_globals.net_phone, device->device_id,
+	    &configuration, count, &data);
+	if (rc != EOK) {
 		fibril_rwlock_write_unlock(&eth_globals.devices_lock);
 		free(device);
-		return ERROR_CODE;
+		return rc;
 	}
 	if (configuration) {
@@ -387,9 +388,10 @@
 	
 	// get hardware address
-	if (ERROR_OCCURRED(netif_get_addr_req(device->phone, device->device_id,
-	    &device->addr, &device->addr_data))) {
+	rc = netif_get_addr_req(device->phone, device->device_id, &device->addr,
+	    &device->addr_data);
+	if (rc != EOK) {
 		fibril_rwlock_write_unlock(&eth_globals.devices_lock);
 		free(device);
-		return ERROR_CODE;
+		return rc;
 	}
 	
@@ -429,6 +431,4 @@
 static eth_proto_ref eth_process_packet(int flags, packet_t packet)
 {
-	ERROR_DECLARE;
-
 	eth_header_snap_ref header;
 	size_t length;
@@ -437,5 +437,6 @@
 	size_t suffix;
 	eth_fcs_ref fcs;
-	uint8_t * data;
+	uint8_t *data;
+	int rc;
 
 	length = packet_get_data_length(packet);
@@ -488,14 +489,17 @@
 	
 	if (IS_DUMMY(flags)) {
-		if ((~compute_crc32(~0U, data, length * 8)) != ntohl(*fcs))
+		if (~compute_crc32(~0U, data, length * 8) != ntohl(*fcs))
 			return NULL;
 		suffix += sizeof(eth_fcs_t);
 	}
 	
-	if (ERROR_OCCURRED(packet_set_addr(packet,
-	    header->header.source_address, header->header.destination_address,
-	    ETH_ADDR)) || ERROR_OCCURRED(packet_trim(packet, prefix, suffix))) {
+	rc = packet_set_addr(packet, header->header.source_address,
+	    header->header.destination_address, ETH_ADDR);
+	if (rc != EOK)
 		return NULL;
-	}
+
+	rc = packet_trim(packet, prefix, suffix);
+	if (rc != EOK)
+		return NULL;
 	
 	return eth_protos_find(&eth_globals.protos, type);
@@ -781,10 +785,9 @@
 eth_send_message(device_id_t device_id, packet_t packet, services_t sender)
 {
-	ERROR_DECLARE;
-
 	eth_device_ref device;
 	packet_t next;
 	packet_t tmp;
 	int ethertype;
+	int rc;
 
 	ethertype = htons(protocol_map(SERVICE_ETHERNET, sender));
@@ -804,6 +807,7 @@
 	next = packet;
 	do {
-		if (ERROR_OCCURRED(eth_prepare_packet(device->flags, next,
-		    (uint8_t *) device->addr->value, ethertype, device->mtu))) {
+		rc = eth_prepare_packet(device->flags, next,
+		    (uint8_t *) device->addr->value, ethertype, device->mtu);
+		if (rc != EOK) {
 			// release invalid packet
 			tmp = pq_detach(next);
@@ -832,6 +836,4 @@
     ipc_call_t *answer, int *answer_count)
 {
-	ERROR_DECLARE;
-	
 	measured_string_ref address;
 	packet_t packet;
@@ -840,4 +842,5 @@
 	size_t suffix;
 	size_t content;
+	int rc;
 	
 	*answer_count = 0;
@@ -850,11 +853,15 @@
 		    IPC_GET_SERVICE(call), IPC_GET_MTU(call));
 	case NET_NIL_SEND:
-		ERROR_PROPAGATE(packet_translate_remote(eth_globals.net_phone,
-		    &packet, IPC_GET_PACKET(call)));
+		rc = packet_translate_remote(eth_globals.net_phone, &packet,
+		    IPC_GET_PACKET(call));
+		if (rc != EOK)
+			return rc;
 		return eth_send_message(IPC_GET_DEVICE(call), packet,
 		    IPC_GET_SERVICE(call));
 	case NET_NIL_PACKET_SPACE:
-		ERROR_PROPAGATE(eth_packet_space_message(IPC_GET_DEVICE(call),
-		    &addrlen, &prefix, &content, &suffix));
+		rc = eth_packet_space_message(IPC_GET_DEVICE(call), &addrlen,
+		    &prefix, &content, &suffix);
+		if (rc != EOK)
+			return rc;
 		IPC_SET_ADDR(answer, addrlen);
 		IPC_SET_PREFIX(answer, prefix);
@@ -864,10 +871,14 @@
 		return EOK;
 	case NET_NIL_ADDR:
-		ERROR_PROPAGATE(eth_addr_message(IPC_GET_DEVICE(call),
-		    ETH_LOCAL_ADDR, &address));
+		rc = eth_addr_message(IPC_GET_DEVICE(call), ETH_LOCAL_ADDR,
+		    &address);
+		if (rc != EOK)
+			return rc;
 		return measured_strings_reply(address, 1);
 	case NET_NIL_BROADCAST_ADDR:
-		ERROR_PROPAGATE(eth_addr_message(IPC_GET_DEVICE(call),
-		    ETH_BROADCAST_ADDR, &address));
+		rc = eth_addr_message(IPC_GET_DEVICE(call), ETH_BROADCAST_ADDR,
+		    &address);
+		if (rc != EOK)
+			return EOK;
 		return measured_strings_reply(address, 1);
 	case IPC_M_CONNECT_TO_ME:
@@ -923,9 +934,9 @@
 int main(int argc, char *argv[])
 {
-	ERROR_DECLARE;
+	int rc;
 	
 	/* Start the module */
-	ERROR_PROPAGATE(nil_module_start_standalone(nil_client_connection));
-	return EOK;
+	rc = nil_module_start_standalone(nil_client_connection);
+	return rc;
 }
 
Index: uspace/srv/net/nil/eth/eth_module.c
===================================================================
--- uspace/srv/net/nil/eth/eth_module.c	(revision 0485135c4340bfe39246c5097af24c53043005de)
+++ uspace/srv/net/nil/eth/eth_module.c	(revision 0b81cad0360a509d54d5a8a7f64c14e5fb6f91e6)
@@ -40,5 +40,5 @@
 #include <async.h>
 #include <stdio.h>
-#include <err.h>
+#include <errno.h>
 
 #include <ipc/ipc.h>
@@ -52,21 +52,27 @@
 int nil_module_start_standalone(async_client_conn_t client_connection)
 {
-	ERROR_DECLARE;
+	ipcarg_t phonehash;
+	int rc;
 	
 	async_set_client_connection(client_connection);
 	int net_phone = net_connect_module();
-	ERROR_PROPAGATE(pm_init());
+
+	rc = pm_init();
+	if (rc != EOK)
+		return rc;
 	
-	ipcarg_t phonehash;
-	if (ERROR_OCCURRED(nil_initialize(net_phone)) ||
-	    ERROR_OCCURRED(REGISTER_ME(SERVICE_ETHERNET, &phonehash))) {
-		pm_destroy();
-		return ERROR_CODE;
-	}
+	rc = nil_initialize(net_phone);
+	if (rc != EOK)
+		goto out;
+
+	rc = REGISTER_ME(SERVICE_ETHERNET, &phonehash);
+	if (rc != EOK)
+		goto out;
 	
 	async_manager();
-	
+
+out:
 	pm_destroy();
-	return EOK;
+	return rc;
 }
 
Index: uspace/srv/net/nil/nildummy/nildummy.c
===================================================================
--- uspace/srv/net/nil/nildummy/nildummy.c	(revision 0485135c4340bfe39246c5097af24c53043005de)
+++ uspace/srv/net/nil/nildummy/nildummy.c	(revision 0b81cad0360a509d54d5a8a7f64c14e5fb6f91e6)
@@ -41,5 +41,4 @@
 #include <stdio.h>
 #include <str.h>
-#include <err.h>
 #include <ipc/ipc.h>
 #include <ipc/net.h>
@@ -82,5 +81,5 @@
 int nil_initialize(int net_phone)
 {
-	ERROR_DECLARE;
+	int rc;
 	
 	fibril_rwlock_initialize(&nildummy_globals.devices_lock);
@@ -91,10 +90,10 @@
 	nildummy_globals.net_phone = net_phone;
 	nildummy_globals.proto.phone = 0;
-	ERROR_CODE = nildummy_devices_initialize(&nildummy_globals.devices);
+	rc = nildummy_devices_initialize(&nildummy_globals.devices);
 	
 	fibril_rwlock_write_unlock(&nildummy_globals.protos_lock);
 	fibril_rwlock_write_unlock(&nildummy_globals.devices_lock);
 	
-	return ERROR_CODE;
+	return rc;
 }
 
@@ -107,24 +106,23 @@
 static void nildummy_receiver(ipc_callid_t iid, ipc_call_t *icall)
 {
-	ERROR_DECLARE;
-
 	packet_t packet;
+	int rc;
 
 	while (true) {
 		switch (IPC_GET_METHOD(*icall)) {
 		case NET_NIL_DEVICE_STATE:
-			ERROR_CODE = nil_device_state_msg_local(0,
+			rc = nil_device_state_msg_local(0,
 			    IPC_GET_DEVICE(icall), IPC_GET_STATE(icall));
-			ipc_answer_0(iid, (ipcarg_t) ERROR_CODE);
+			ipc_answer_0(iid, (ipcarg_t) rc);
 			break;
 		
 		case NET_NIL_RECEIVED:
-			if (ERROR_NONE(packet_translate_remote(
-			    nildummy_globals.net_phone, &packet,
-			    IPC_GET_PACKET(icall)))) {
-				ERROR_CODE = nil_received_msg_local(0,
+			rc = packet_translate_remote(nildummy_globals.net_phone,
+			    &packet, IPC_GET_PACKET(icall));
+			if (rc == EOK) {
+				rc = nil_received_msg_local(0,
 				    IPC_GET_DEVICE(icall), packet, 0);
 			}
-			ipc_answer_0(iid, (ipcarg_t) ERROR_CODE);
+			ipc_answer_0(iid, (ipcarg_t) rc);
 			break;
 		
@@ -155,8 +153,7 @@
 nildummy_device_message(device_id_t device_id, services_t service, size_t mtu)
 {
-	ERROR_DECLARE;
-
 	nildummy_device_ref device;
 	int index;
+	int rc;
 
 	fibril_rwlock_write_lock(&nildummy_globals.devices_lock);
@@ -216,9 +213,10 @@
 	
 	// get hardware address
-	if (ERROR_OCCURRED(netif_get_addr_req(device->phone, device->device_id,
-	    &device->addr, &device->addr_data))) {
+	rc = netif_get_addr_req(device->phone, device->device_id, &device->addr,
+	    &device->addr_data);
+	if (rc != EOK) {
 		fibril_rwlock_write_unlock(&nildummy_globals.devices_lock);
 		free(device);
-		return ERROR_CODE;
+		return rc;
 	}
 	
@@ -380,6 +378,4 @@
     ipc_call_t *answer, int *answer_count)
 {
-	ERROR_DECLARE;
-	
 	measured_string_ref address;
 	packet_t packet;
@@ -388,4 +384,5 @@
 	size_t suffix;
 	size_t content;
+	int rc;
 	
 	*answer_count = 0;
@@ -399,13 +396,16 @@
 	
 	case NET_NIL_SEND:
-		ERROR_PROPAGATE(packet_translate_remote(
-		    nildummy_globals.net_phone, &packet, IPC_GET_PACKET(call)));
+		rc = packet_translate_remote(nildummy_globals.net_phone,
+		    &packet, IPC_GET_PACKET(call));
+		if (rc != EOK)
+			return rc;
 		return nildummy_send_message(IPC_GET_DEVICE(call), packet,
 		    IPC_GET_SERVICE(call));
 	
 	case NET_NIL_PACKET_SPACE:
-		ERROR_PROPAGATE(nildummy_packet_space_message(
-		    IPC_GET_DEVICE(call), &addrlen, &prefix, &content,
-		    &suffix));
+		rc = nildummy_packet_space_message(IPC_GET_DEVICE(call),
+		    &addrlen, &prefix, &content, &suffix);
+		if (rc != EOK)
+			return rc;
 		IPC_SET_ADDR(answer, addrlen);
 		IPC_SET_PREFIX(answer, prefix);
@@ -416,11 +416,13 @@
 	
 	case NET_NIL_ADDR:
-		ERROR_PROPAGATE(nildummy_addr_message(IPC_GET_DEVICE(call),
-		    &address));
+		rc = nildummy_addr_message(IPC_GET_DEVICE(call), &address);
+		if (rc != EOK)
+			return rc;
 		return measured_strings_reply(address, 1);
 	
 	case NET_NIL_BROADCAST_ADDR:
-		ERROR_PROPAGATE(nildummy_addr_message(IPC_GET_DEVICE(call),
-		    &address));
+		rc = nildummy_addr_message(IPC_GET_DEVICE(call), &address);
+		if (rc != EOK)
+			return rc;
 		return measured_strings_reply(address, 1);
 	
@@ -476,9 +478,9 @@
 int main(int argc, char *argv[])
 {
-	ERROR_DECLARE;
+	int rc;
 	
 	/* Start the module */
-	ERROR_PROPAGATE(nil_module_start_standalone(nil_client_connection));
-	return EOK;
+	rc = nil_module_start_standalone(nil_client_connection);
+	return rc;
 }
 
Index: uspace/srv/net/nil/nildummy/nildummy.h
===================================================================
--- uspace/srv/net/nil/nildummy/nildummy.h	(revision 0485135c4340bfe39246c5097af24c53043005de)
+++ uspace/srv/net/nil/nildummy/nildummy.h	(revision 0b81cad0360a509d54d5a8a7f64c14e5fb6f91e6)
@@ -62,5 +62,5 @@
  * @see nildummy_proto
  */
-typedef struct nildummy_proto	nildummy_proto_t;
+typedef struct nildummy_proto nildummy_proto_t;
 
 /** Type definition of the dummy nil protocol specific data pointer.
@@ -100,5 +100,5 @@
 
 /** Dummy nil global data. */
-struct	nildummy_globals {
+struct nildummy_globals {
 	/** Networking module phone. */
 	int net_phone;
Index: uspace/srv/net/nil/nildummy/nildummy_module.c
===================================================================
--- uspace/srv/net/nil/nildummy/nildummy_module.c	(revision 0485135c4340bfe39246c5097af24c53043005de)
+++ uspace/srv/net/nil/nildummy/nildummy_module.c	(revision 0b81cad0360a509d54d5a8a7f64c14e5fb6f91e6)
@@ -38,5 +38,5 @@
 #include <async.h>
 #include <stdio.h>
-#include <err.h>
+#include <errno.h>
 
 #include <ipc/ipc.h>
@@ -52,21 +52,28 @@
 int nil_module_start_standalone(async_client_conn_t client_connection)
 {
-	ERROR_DECLARE;
+	ipcarg_t phonehash;
+	int rc;
 	
 	async_set_client_connection(client_connection);
 	int net_phone = net_connect_module();
-	ERROR_PROPAGATE(pm_init());
 	
-	ipcarg_t phonehash;
-	if (ERROR_OCCURRED(nil_initialize(net_phone)) ||
-	    ERROR_OCCURRED(REGISTER_ME(SERVICE_NILDUMMY, &phonehash))) {
-		pm_destroy();
-		return ERROR_CODE;
-	}
+	rc = pm_init();
+	if (rc != EOK)
+		return rc;
+	
+	
+	rc = nil_initialize(net_phone);
+	if (rc != EOK)
+		goto out;
+	
+	rc = REGISTER_ME(SERVICE_NILDUMMY, &phonehash);
+	if (rc != EOK)
+		goto out;
 	
 	async_manager();
-	
+
+out:
 	pm_destroy();
-	return EOK;
+	return rc;
 }
 
Index: uspace/srv/net/tl/icmp/icmp.c
===================================================================
--- uspace/srv/net/tl/icmp/icmp.c	(revision 0485135c4340bfe39246c5097af24c53043005de)
+++ uspace/srv/net/tl/icmp/icmp.c	(revision 0b81cad0360a509d54d5a8a7f64c14e5fb6f91e6)
@@ -54,5 +54,4 @@
 #include <byteorder.h>
 #include <errno.h>
-#include <err.h>
 
 #include <net/socket_codes.h>
@@ -161,5 +160,5 @@
     int dont_fragment)
 {
-	ERROR_DECLARE;
+	int rc;
 
 	// do not send an error if disabled
@@ -172,8 +171,9 @@
 	header->checksum = ICMP_CHECKSUM(header,
 	    packet_get_data_length(packet));
-	if (ERROR_OCCURRED(ip_client_prepare_packet(packet, IPPROTO_ICMP, ttl,
-	    tos, dont_fragment, 0))) {
-		return icmp_release_and_return(packet, ERROR_CODE);
-	}
+	
+	rc = ip_client_prepare_packet(packet, IPPROTO_ICMP, ttl, tos,
+	    dont_fragment, 0);
+	if (rc != EOK)
+		return icmp_release_and_return(packet, rc);
 
 	return ip_send_msg(icmp_globals.ip_phone, -1, packet, SERVICE_ICMP,
@@ -249,6 +249,4 @@
     const struct sockaddr * addr, socklen_t addrlen)
 {
-	ERROR_DECLARE;
-
 	icmp_header_ref header;
 	packet_t packet;
@@ -257,6 +255,6 @@
 	icmp_reply_ref reply;
 	int reply_key;
-	int result;
 	int index;
+	int rc;
 
 	if (addrlen <= 0)
@@ -265,6 +263,8 @@
 	length = (size_t) addrlen;
 	// TODO do not ask all the time
-	ERROR_PROPAGATE(ip_packet_size_req(icmp_globals.ip_phone, -1,
-	    &icmp_globals.packet_dimension));
+	rc = ip_packet_size_req(icmp_globals.ip_phone, -1,
+	    &icmp_globals.packet_dimension);
+	if (rc != EOK)
+		return rc;
 
 	packet = packet_get_4_remote(icmp_globals.net_phone, size,
@@ -277,8 +277,7 @@
 	// prepare the requesting packet
 	// set the destination address
-	if (ERROR_OCCURRED(packet_set_addr(packet, NULL, (const uint8_t *) addr,
-	    length))) {
-		return icmp_release_and_return(packet, ERROR_CODE);
-	}
+	rc = packet_set_addr(packet, NULL, (const uint8_t *) addr, length);
+	if (rc != EOK)
+		return icmp_release_and_return(packet, rc);
 
 	// allocate space in the packet
@@ -329,11 +328,8 @@
 	// wait for the reply
 	// timeout in microseconds
-	if (ERROR_OCCURRED(fibril_condvar_wait_timeout(&reply->condvar,
-	    &reply->mutex, timeout * 1000))) {
-		result = ERROR_CODE;
-	} else {
-		// read the result
-		result = reply->result;
-	}
+	rc = fibril_condvar_wait_timeout(&reply->condvar, &reply->mutex,
+	    timeout * 1000);
+	if (rc == EOK)
+		rc = reply->result;
 
 	// drop the reply mutex before locking the globals again
@@ -344,5 +340,5 @@
 	icmp_replies_exclude_index(&icmp_globals.replies, index);
 
-	return result;
+	return rc;
 }
 
@@ -413,6 +409,4 @@
 int icmp_initialize(async_client_conn_t client_connection)
 {
-	ERROR_DECLARE;
-
 	measured_string_t names[] = {
 		{
@@ -428,4 +422,5 @@
 	size_t count = sizeof(names) / sizeof(measured_string_t);
 	char *data;
+	int rc;
 
 	fibril_rwlock_initialize(&icmp_globals.lock);
@@ -433,11 +428,19 @@
 	icmp_replies_initialize(&icmp_globals.replies);
 	icmp_echo_data_initialize(&icmp_globals.echo_data);
+	
 	icmp_globals.ip_phone = ip_bind_service(SERVICE_IP, IPPROTO_ICMP,
 	    SERVICE_ICMP, client_connection);
-	if (icmp_globals.ip_phone < 0)
+	if (icmp_globals.ip_phone < 0) {
+		fibril_rwlock_write_unlock(&icmp_globals.lock);
 		return icmp_globals.ip_phone;
-
-	ERROR_PROPAGATE(ip_packet_size_req(icmp_globals.ip_phone, -1,
-	    &icmp_globals.packet_dimension));
+	}
+	
+	rc = ip_packet_size_req(icmp_globals.ip_phone, -1,
+	    &icmp_globals.packet_dimension);
+	if (rc != EOK) {
+		fibril_rwlock_write_unlock(&icmp_globals.lock);
+		return rc;
+	}
+
 	icmp_globals.packet_dimension.prefix += ICMP_HEADER_SIZE;
 	icmp_globals.packet_dimension.content -= ICMP_HEADER_SIZE;
@@ -448,6 +451,11 @@
 	// get configuration
 	configuration = &names[0];
-	ERROR_PROPAGATE(net_get_conf_req(icmp_globals.net_phone, &configuration,
-	    count, &data));
+	rc = net_get_conf_req(icmp_globals.net_phone, &configuration, count,
+	    &data);
+	if (rc != EOK) {
+		fibril_rwlock_write_unlock(&icmp_globals.lock);
+		return rc;
+	}
+	
 	if (configuration) {
 		if (configuration[0].value) {
@@ -519,6 +527,4 @@
 static int icmp_process_packet(packet_t packet, services_t error)
 {
-	ERROR_DECLARE;
-
 	size_t length;
 	uint8_t *src;
@@ -529,4 +535,5 @@
 	icmp_type_t type;
 	icmp_code_t code;
+	int rc;
 
 	switch (error) {
@@ -541,5 +548,7 @@
 		length = (size_t) result;
 		// remove the error header
-		ERROR_PROPAGATE(packet_trim(packet, length, 0));
+		rc = packet_trim(packet, length, 0);
+		if (rc != EOK)
+			return rc;
 		break;
 	default:
@@ -549,5 +558,7 @@
 	// get rid of the ip header
 	length = ip_client_header_length(packet);
-	ERROR_PROPAGATE(packet_trim(packet, length, 0));
+	rc = packet_trim(packet, length, 0);
+	if (rc != EOK)
+		return rc;
 
 	length = packet_get_data_length(packet);
@@ -582,5 +593,5 @@
 	switch (header->type) {
 	case ICMP_ECHOREPLY:
-		if (error) 
+		if (error)
 			icmp_process_echo_reply(packet, header, type, code);
 		else
@@ -654,8 +665,9 @@
     services_t receiver, services_t error)
 {
-	ERROR_DECLARE;
-
-	if (ERROR_OCCURRED(icmp_process_packet(packet, error)))
-		return icmp_release_and_return(packet, ERROR_CODE);
+	int rc;
+
+	rc = icmp_process_packet(packet, error);
+	if (rc != EOK)
+		return icmp_release_and_return(packet, rc);
 
 	return EOK;
@@ -682,37 +694,35 @@
 static int icmp_process_message(ipc_call_t *call)
 {
-	ERROR_DECLARE;
-
 	packet_t packet;
+	int rc;
 
 	switch (IPC_GET_METHOD(*call)) {
 	case NET_ICMP_DEST_UNREACH:
-		if (ERROR_NONE(packet_translate_remote(icmp_globals.net_phone,
-		    &packet, IPC_GET_PACKET(call)))) {
-			ERROR_CODE = icmp_destination_unreachable_msg_local(0,
-			    ICMP_GET_CODE(call), ICMP_GET_MTU(call), packet);
-		}
-		return ERROR_CODE;
+		rc = packet_translate_remote(icmp_globals.net_phone, &packet,
+		    IPC_GET_PACKET(call));
+		if (rc != EOK)
+			return rc;
+		return icmp_destination_unreachable_msg_local(0,
+		    ICMP_GET_CODE(call), ICMP_GET_MTU(call), packet);
 	case NET_ICMP_SOURCE_QUENCH:
-		if (ERROR_NONE(packet_translate_remote(icmp_globals.net_phone,
-		    &packet, IPC_GET_PACKET(call)))) {
-			ERROR_CODE = icmp_source_quench_msg_local(0, packet);
-		}
-		return ERROR_CODE;
+		rc = packet_translate_remote(icmp_globals.net_phone, &packet,
+		    IPC_GET_PACKET(call));
+		if (rc != EOK)
+			return rc;
+		return icmp_source_quench_msg_local(0, packet);
 	case NET_ICMP_TIME_EXCEEDED:
-		if (ERROR_NONE(packet_translate_remote(icmp_globals.net_phone,
-		    &packet, IPC_GET_PACKET(call)))) {
-			ERROR_CODE = icmp_time_exceeded_msg_local(0,
-			    ICMP_GET_CODE(call), packet);
-		}
-		return ERROR_CODE;
+		rc = packet_translate_remote(icmp_globals.net_phone, &packet,
+		    IPC_GET_PACKET(call));
+		if (rc != EOK)
+			return rc;
+		return icmp_time_exceeded_msg_local(0, ICMP_GET_CODE(call),
+		    packet);
 	case NET_ICMP_PARAMETERPROB:
-		if (ERROR_NONE(packet_translate_remote(icmp_globals.net_phone,
-		    &packet, IPC_GET_PACKET(call)))) {
-			ERROR_CODE = icmp_parameter_problem_msg_local(0,
-			    ICMP_GET_CODE(call), ICMP_GET_POINTER(call),
-			    packet);
-		}
-		return ERROR_CODE;
+		rc = packet_translate_remote(icmp_globals.net_phone, &packet,
+		    IPC_GET_PACKET(call));
+		if (rc != EOK)
+			return rc;
+		return icmp_parameter_problem_msg_local(0, ICMP_GET_CODE(call),
+		    ICMP_GET_POINTER(call), packet);
 	default:
 		return ENOTSUP;
@@ -757,5 +767,5 @@
 			break;
 		}
-	} while(icmp_echo_data_find(&icmp_globals.echo_data, index) != NULL);
+	} while (icmp_echo_data_find(&icmp_globals.echo_data, index) != NULL);
 
 	echo_data->identifier = index;
@@ -779,6 +789,4 @@
 static int icmp_process_client_messages(ipc_callid_t callid, ipc_call_t call)
 {
-	ERROR_DECLARE;
-
 	bool keep_on_going = true;
 	ipc_call_t answer;
@@ -788,5 +796,5 @@
 	ipc_callid_t data_callid;
 	icmp_echo_ref echo_data;
-	int res;
+	int rc = EOK;
 
 	/*
@@ -794,5 +802,4 @@
 	 *  - Answer the first NET_ICMP_INIT call.
 	 */
-	res = EOK;
 	answer_count = 0;
 
@@ -803,14 +810,14 @@
 	// assign a new identifier
 	fibril_rwlock_write_lock(&icmp_globals.lock);
-	res = icmp_bind_free_id(echo_data);
+	rc = icmp_bind_free_id(echo_data);
 	fibril_rwlock_write_unlock(&icmp_globals.lock);
-	if (res < 0) {
+	if (rc < 0) {
 		free(echo_data);
-		return res;
+		return rc;
 	}
 
 	while (keep_on_going) {
 		// answer the call
-		answer_call(callid, res, &answer, answer_count);
+		answer_call(callid, rc, &answer, answer_count);
 
 		// refresh data
@@ -824,10 +831,10 @@
 		case IPC_M_PHONE_HUNGUP:
 			keep_on_going = false;
-			res = EHANGUP;
+			rc = EHANGUP;
 			break;
 		
 		case NET_ICMP_ECHO:
 			if (!async_data_write_receive(&data_callid, &length)) {
-				res = EINVAL;
+				rc = EINVAL;
 				break;
 			}
@@ -835,17 +842,17 @@
 			addr = malloc(length);
 			if (!addr) {
-				res = ENOMEM;
+				rc = ENOMEM;
 				break;
 			}
 			
-			if (ERROR_OCCURRED(async_data_write_finalize(
-			    data_callid, addr, length))) {
+			rc = async_data_write_finalize(data_callid, addr,
+			    length);
+			if (rc != EOK) {
 				free(addr);
-				res = ERROR_CODE;
 				break;
 			}
 
 			fibril_rwlock_write_lock(&icmp_globals.lock);
-			res = icmp_echo(echo_data->identifier,
+			rc = icmp_echo(echo_data->identifier,
 			    echo_data->sequence_number, ICMP_GET_SIZE(call),
 			    ICMP_GET_TIMEOUT(call), ICMP_GET_TTL(call),
@@ -864,5 +871,5 @@
 
 		default:
-			res = icmp_process_message(&call);
+			rc = icmp_process_message(&call);
 		}
 
@@ -874,5 +881,5 @@
 	fibril_rwlock_write_unlock(&icmp_globals.lock);
 
-	return res;
+	return rc;
 }
 
@@ -894,18 +901,16 @@
     ipc_call_t *answer, int *answer_count)
 {
-	ERROR_DECLARE;
-
 	packet_t packet;
+	int rc;
 
 	*answer_count = 0;
 	switch (IPC_GET_METHOD(*call)) {
 	case NET_TL_RECEIVED:
-		if (ERROR_NONE(packet_translate_remote(icmp_globals.net_phone,
-		    &packet, IPC_GET_PACKET(call)))) {
-			ERROR_CODE =
-			    icmp_received_msg_local(IPC_GET_DEVICE(call),
-			    packet, SERVICE_ICMP, IPC_GET_ERROR(call));
-		}
-		return ERROR_CODE;
+		rc = packet_translate_remote(icmp_globals.net_phone, &packet,
+		    IPC_GET_PACKET(call));
+		if (rc != EOK)
+			return rc;
+		return icmp_received_msg_local(IPC_GET_DEVICE(call), packet,
+		    SERVICE_ICMP, IPC_GET_ERROR(call));
 	
 	case NET_ICMP_INIT:
@@ -970,9 +975,9 @@
 int main(int argc, char *argv[])
 {
-	ERROR_DECLARE;
+	int rc;
 	
 	/* Start the module */
-	ERROR_PROPAGATE(tl_module_start_standalone(tl_client_connection));
-	return EOK;
+	rc = tl_module_start_standalone(tl_client_connection);
+	return rc;
 }
 
Index: uspace/srv/net/tl/icmp/icmp_module.c
===================================================================
--- uspace/srv/net/tl/icmp/icmp_module.c	(revision 0485135c4340bfe39246c5097af24c53043005de)
+++ uspace/srv/net/tl/icmp/icmp_module.c	(revision 0b81cad0360a509d54d5a8a7f64c14e5fb6f91e6)
@@ -43,5 +43,5 @@
 #include <async.h>
 #include <stdio.h>
-#include <err.h>
+#include <errno.h>
 #include <ipc/ipc.h>
 #include <ipc/services.h>
@@ -58,7 +58,6 @@
 int tl_module_start_standalone(async_client_conn_t client_connection)
 {
-	ERROR_DECLARE;
-
 	ipcarg_t phonehash;
+	int rc;
 
 	async_set_client_connection(client_connection);
@@ -67,15 +66,21 @@
 		return icmp_globals.net_phone;
 
-	ERROR_PROPAGATE(pm_init());
-	if (ERROR_OCCURRED(icmp_initialize(client_connection)) ||
-	    ERROR_OCCURRED(REGISTER_ME(SERVICE_ICMP, &phonehash))) {
-		pm_destroy();
-		return ERROR_CODE;
-	}
+	rc = pm_init();
+	if (rc != EOK)
+		return rc;
+	
+	rc = icmp_initialize(client_connection);
+	if (rc != EOK)
+		goto out;
+
+	rc = REGISTER_ME(SERVICE_ICMP, &phonehash);
+	if (rc != EOK)
+		goto out;
 
 	async_manager();
 
+out:
 	pm_destroy();
-	return EOK;
+	return rc;
 }
 
@@ -89,3 +94,2 @@
 /** @}
  */
-
Index: uspace/srv/net/tl/tcp/tcp.c
===================================================================
--- uspace/srv/net/tl/tcp/tcp.c	(revision 0485135c4340bfe39246c5097af24c53043005de)
+++ uspace/srv/net/tl/tcp/tcp.c	(revision 0b81cad0360a509d54d5a8a7f64c14e5fb6f91e6)
@@ -47,5 +47,4 @@
 #include <stdio.h>
 #include <errno.h>
-#include <err.h>
 
 #include <ipc/ipc.h>
@@ -235,5 +234,5 @@
 int tcp_initialize(async_client_conn_t client_connection)
 {
-	ERROR_DECLARE;
+	int rc;
 
 	assert(client_connection);
@@ -246,18 +245,24 @@
 	tcp_globals.ip_phone = ip_bind_service(SERVICE_IP, IPPROTO_TCP,
 	    SERVICE_TCP, client_connection);
-	if (tcp_globals.ip_phone < 0)
+	if (tcp_globals.ip_phone < 0) {
+		fibril_rwlock_write_unlock(&tcp_globals.lock);
 		return tcp_globals.ip_phone;
+	}
 	
-	ERROR_PROPAGATE(socket_ports_initialize(&tcp_globals.sockets));
-	if (ERROR_OCCURRED(packet_dimensions_initialize(
-	    &tcp_globals.dimensions))) {
+	rc = socket_ports_initialize(&tcp_globals.sockets);
+	if (rc != EOK)
+		goto out;
+
+	rc = packet_dimensions_initialize(&tcp_globals.dimensions);
+	if (rc != EOK) {
 		socket_ports_destroy(&tcp_globals.sockets);
-		return ERROR_CODE;
+		goto out;
 	}
 
 	tcp_globals.last_used_port = TCP_FREE_PORTS_START - 1;
+
+out:
 	fibril_rwlock_write_unlock(&tcp_globals.lock);
-
-	return EOK;
+	return rc;
 }
 
@@ -266,5 +271,5 @@
     services_t error)
 {
-	ERROR_DECLARE;
+	int rc;
 
 	if (receiver != SERVICE_TCP)
@@ -272,16 +277,15 @@
 
 	fibril_rwlock_write_lock(&tcp_globals.lock);
-	if (ERROR_OCCURRED(tcp_process_packet(device_id, packet, error)))
+	rc = tcp_process_packet(device_id, packet, error);
+	if (rc != EOK)
 		fibril_rwlock_write_unlock(&tcp_globals.lock);
 
-	printf("receive %d \n", ERROR_CODE);
-
-	return ERROR_CODE;
+	printf("receive %d \n", rc);
+
+	return rc;
 }
 
 int tcp_process_packet(device_id_t device_id, packet_t packet, services_t error)
 {
-	ERROR_DECLARE;
-
 	size_t length;
 	size_t offset;
@@ -299,4 +303,5 @@
 	struct sockaddr *dest;
 	size_t addrlen;
+	int rc;
 
 	switch (error) {
@@ -311,6 +316,7 @@
 
 		length = (size_t) result;
-		if (ERROR_OCCURRED(packet_trim(packet, length, 0)))
-			return tcp_release_and_return(packet, ERROR_CODE);
+		rc = packet_trim(packet, length, 0);
+		if (rc != EOK)
+			return tcp_release_and_return(packet, rc);
 		break;
 	default:
@@ -333,6 +339,7 @@
 
 	// trim all but TCP header
-	if (ERROR_OCCURRED(packet_trim(packet, offset, 0)))
-		return tcp_release_and_return(packet, ERROR_CODE);
+	rc = packet_trim(packet, offset, 0);
+	if (rc != EOK)
+		return tcp_release_and_return(packet, rc);
 
 	// get tcp header
@@ -350,7 +357,7 @@
 	addrlen = (size_t) result;
 
-	if (ERROR_OCCURRED(tl_set_address_port(src, addrlen,
-	    ntohs(header->source_port)))) 
-		return tcp_release_and_return(packet, ERROR_CODE);
+	rc = tl_set_address_port(src, addrlen, ntohs(header->source_port));
+	if (rc != EOK)
+		return tcp_release_and_return(packet, rc);
 	
 	// find the destination socket
@@ -413,16 +420,19 @@
 		}
 
-		if (ERROR_OCCURRED(ip_client_get_pseudo_header(IPPROTO_TCP, src,
-		    addrlen, dest, addrlen, total_length,
-		    &socket_data->pseudo_header, &socket_data->headerlen))) {
+		rc = ip_client_get_pseudo_header(IPPROTO_TCP, src, addrlen,
+		    dest, addrlen, total_length, &socket_data->pseudo_header,
+		    &socket_data->headerlen);
+		if (rc != EOK) {
 			fibril_rwlock_write_unlock(socket_data->local_lock);
-			return tcp_release_and_return(packet, ERROR_CODE);
-		}
-
-	} else if (ERROR_OCCURRED(ip_client_set_pseudo_header_data_length(
-	    socket_data->pseudo_header, socket_data->headerlen,
-	    total_length))) {
-		fibril_rwlock_write_unlock(socket_data->local_lock);
-		return tcp_release_and_return(packet, ERROR_CODE);
+			return tcp_release_and_return(packet, rc);
+		}
+	} else {
+		rc = ip_client_set_pseudo_header_data_length(
+		    socket_data->pseudo_header, socket_data->headerlen,
+		    total_length);
+		if (rc != EOK) {
+			fibril_rwlock_write_unlock(socket_data->local_lock);
+			return tcp_release_and_return(packet, rc);
+		}
 	}
 	
@@ -434,6 +444,7 @@
 		fibril_rwlock_write_unlock(socket_data->local_lock);
 
-		if (ERROR_NONE(tl_prepare_icmp_packet(tcp_globals.net_phone,
-		    tcp_globals.icmp_phone, packet, error))) {
+		rc = tl_prepare_icmp_packet(tcp_globals.net_phone,
+		    tcp_globals.icmp_phone, packet, error);
+		if (rc == EOK) {
 			// checksum error ICMP
 			icmp_parameter_problem_msg(tcp_globals.icmp_phone,
@@ -452,14 +463,13 @@
 	switch (socket_data->state) {
 	case TCP_SOCKET_LISTEN:
-		ERROR_CODE = tcp_process_listen(socket, socket_data, header,
-		    packet, src, dest, addrlen);
+		rc = tcp_process_listen(socket, socket_data, header, packet,
+		    src, dest, addrlen);
 		break;
 	case TCP_SOCKET_SYN_RECEIVED:
-		ERROR_CODE = tcp_process_syn_received(socket, socket_data,
-		    header, packet);
+		rc = tcp_process_syn_received(socket, socket_data, header,
+		    packet);
 		break;
 	case TCP_SOCKET_SYN_SENT:
-		ERROR_CODE = tcp_process_syn_sent(socket, socket_data, header,
-		    packet);
+		rc = tcp_process_syn_sent(socket, socket_data, header, packet);
 		break;
 	case TCP_SOCKET_FIN_WAIT_1:
@@ -472,6 +482,6 @@
 		// ack releasing the socket gets processed later
 	case TCP_SOCKET_ESTABLISHED:
-		ERROR_CODE = tcp_process_established(socket, socket_data,
-		    header, packet, fragments, total_length);
+		rc = tcp_process_established(socket, socket_data, header,
+		    packet, fragments, total_length);
 		break;
 	default:
@@ -479,7 +489,7 @@
 	}
 
-	if (ERROR_CODE != EOK) {
-		printf("process %d\n", ERROR_CODE);
+	if (rc != EOK) {
 		fibril_rwlock_write_unlock(socket_data->local_lock);
+		printf("process %d\n", rc);
 	}
 
@@ -491,6 +501,4 @@
     tcp_header_ref header, packet_t packet, int fragments, size_t total_length)
 {
-	ERROR_DECLARE;
-
 	packet_t next_packet;
 	packet_t tmp_packet;
@@ -501,4 +509,5 @@
 	size_t offset;
 	uint32_t new_sequence_number;
+	int rc;
 
 	assert(socket);
@@ -541,7 +550,9 @@
 		}
 
-		if ((offset > 0) && (ERROR_OCCURRED(packet_trim(packet,
-		    offset, 0))))
-			return tcp_release_and_return(packet, ERROR_CODE);
+		if (offset > 0) {
+			rc = packet_trim(packet, offset, 0);
+			if (rc != EOK)
+				return tcp_release_and_return(packet, rc);
+		}
 
 		assert(new_sequence_number == socket_data->next_incoming);
@@ -575,8 +586,11 @@
 			if (length <= offset)
 				next_packet = pq_next(next_packet);
-			else if (ERROR_OCCURRED(packet_trim(next_packet, 0,
-			    length - offset)))
-				return tcp_release_and_return(packet,
-				    ERROR_CODE);
+			else {
+				rc = packet_trim(next_packet, 0,
+				    length - offset));
+				if (rc != EOK)
+					return tcp_release_and_return(packet,
+					    rc);
+			}
 			offset -= length;
 			total_length -= length - offset;
@@ -603,11 +617,13 @@
 		// remove the header
 		total_length -= TCP_HEADER_LENGTH(header);
-		if (ERROR_OCCURRED(packet_trim(packet,
-		    TCP_HEADER_LENGTH(header), 0)))
-			return tcp_release_and_return(packet, ERROR_CODE);
+		rc = packet_trim(packet, TCP_HEADER_LENGTH(header), 0);
+		if (rc != EOK)
+			return tcp_release_and_return(packet, rc);
 
 		if (total_length) {
-			ERROR_PROPAGATE(tcp_queue_received_packet(socket,
-			    socket_data, packet, fragments, total_length));
+			rc = tcp_queue_received_packet(socket, socket_data,
+			    packet, fragments, total_length);
+			if (rc != EOK)
+				return rc;
 		} else {
 			total_length = 1;
@@ -617,7 +633,6 @@
 		packet = socket_data->incoming;
 		while (packet) {
-
-			if (ERROR_OCCURRED(pq_get_order(socket_data->incoming,
-			    &order, NULL))) {
+			rc = pq_get_order(socket_data->incoming, &order, NULL);
+			if (rc != EOK) {
 				// remove the corrupted packet
 				next_packet = pq_detach(packet);
@@ -656,8 +671,9 @@
 				    socket_data->next_incoming) {
 					// queue received data
-					ERROR_PROPAGATE(
-					    tcp_queue_received_packet(socket,
+					rc = tcp_queue_received_packet(socket,
 					    socket_data, packet, 1,
-					    packet_get_data_length(packet)));
+					    packet_get_data_length(packet));
+					if (rc != EOK)
+						return rc;
 					socket_data->next_incoming =
 					    new_sequence_number;
@@ -677,12 +693,13 @@
 						    new_sequence_number;
 					}
-					if (ERROR_NONE(packet_trim(packet,
-					    length, 0))) {
+					rc = packet_trim(packet,length, 0);
+					if (rc == EOK) {
 						// queue received data
-						ERROR_PROPAGATE(
-						    tcp_queue_received_packet(
+						rc = tcp_queue_received_packet(
 						    socket, socket_data, packet,
 						    1, packet_get_data_length(
-						    packet)));
+						    packet));
+						if (rc != EOK)
+							return rc;
 						socket_data->next_incoming =
 						    new_sequence_number;
@@ -709,12 +726,13 @@
 		// remove the header
 		total_length -= TCP_HEADER_LENGTH(header);
-		if (ERROR_OCCURRED(packet_trim(packet,
-		    TCP_HEADER_LENGTH(header), 0)))
-			return tcp_release_and_return(packet, ERROR_CODE);
+		rc = packet_trim(packet, TCP_HEADER_LENGTH(header), 0);
+		if (rc != EOK)
+			return tcp_release_and_return(packet, rc);
 
 		next_packet = pq_detach(packet);
 		length = packet_get_data_length(packet);
-		if (ERROR_OCCURRED(pq_add(&socket_data->incoming, packet,
-		    new_sequence_number, length))) {
+		rc = pq_add(&socket_data->incoming, packet, new_sequence_number,
+		    length);
+		if (rc != EOK) {
 			// remove the corrupted packets
 			pq_release_remote(tcp_globals.net_phone,
@@ -727,8 +745,13 @@
 				tmp_packet = pq_detach(next_packet);
 				length = packet_get_data_length(next_packet);
-				if (ERROR_OCCURRED(pq_set_order(next_packet,
-				    new_sequence_number, length)) ||
-				    ERROR_OCCURRED(pq_insert_after(packet,
-				    next_packet))) {
+
+				rc = pq_set_order(next_packet,
+				    new_sequence_number, length);
+				if (rc != EOK) {
+					pq_release_remote(tcp_globals.net_phone,
+					    packet_get_id(next_packet));
+				}
+				rc = pq_insert_after(packet, next_packet);
+				if (rc != EOK) {
 					pq_release_remote(tcp_globals.net_phone,
 					    packet_get_id(next_packet));
@@ -762,8 +785,11 @@
 	if (!packet) {
 		// create the notification packet
-		ERROR_PROPAGATE(tcp_create_notification_packet(&packet, socket,
-		    socket_data, 0, 0));
-		ERROR_PROPAGATE(tcp_queue_prepare_packet(socket, socket_data,
-		    packet, 1));
+		rc = tcp_create_notification_packet(&packet, socket,
+		    socket_data, 0, 0);
+		if (rc != EOK)
+			return rc;
+		rc = tcp_queue_prepare_packet(socket, socket_data, packet, 1);
+		if (rc != EOK)
+			return rc;
 		packet = tcp_send_prepare_packet(socket, socket_data, packet, 1,
 		    socket_data->last_outgoing + 1);
@@ -783,7 +809,6 @@
     size_t total_length)
 {
-	ERROR_DECLARE;
-
 	packet_dimension_ref packet_dimension;
+	int rc;
 
 	assert(socket);
@@ -795,11 +820,12 @@
 
 	// queue the received packet
-	if (ERROR_OCCURRED(dyn_fifo_push(&socket->received,
-	    packet_get_id(packet), SOCKET_MAX_RECEIVED_SIZE)) ||
-	    ERROR_OCCURRED(tl_get_ip_packet_dimension(tcp_globals.ip_phone,
-	    &tcp_globals.dimensions, socket_data->device_id,
-	    &packet_dimension))) {
-		return tcp_release_and_return(packet, ERROR_CODE);
-	}
+	rc = dyn_fifo_push(&socket->received, packet_get_id(packet),
+	    SOCKET_MAX_RECEIVED_SIZE);
+	if (rc != EOK)
+		return tcp_release_and_return(packet, rc);
+	rc = tl_get_ip_packet_dimension(tcp_globals.ip_phone,
+	    &tcp_globals.dimensions, socket_data->device_id, &packet_dimension);
+	if (rc != EOK)
+		return tcp_release_and_return(packet, rc);
 
 	// decrease the window size
@@ -820,7 +846,6 @@
     tcp_header_ref header, packet_t packet)
 {
-	ERROR_DECLARE;
-
 	packet_t next_packet;
+	int rc;
 
 	assert(socket);
@@ -844,8 +869,9 @@
 	}
 	// trim if longer than the header
-	if ((packet_get_data_length(packet) > sizeof(*header)) &&
-	    ERROR_OCCURRED(packet_trim(packet, 0,
-	    packet_get_data_length(packet) - sizeof(*header)))) {
-		return tcp_release_and_return(packet, ERROR_CODE);
+	if (packet_get_data_length(packet) > sizeof(*header)) {
+		rc = packet_trim(packet, 0,
+		    packet_get_data_length(packet) - sizeof(*header));
+		if (rc != EOK)
+			return tcp_release_and_return(packet, rc);
 	}
 	tcp_prepare_operation_header(socket, socket_data, header, 0, 0);
@@ -876,6 +902,4 @@
     size_t addrlen)
 {
-	ERROR_DECLARE;
-
 	packet_t next_packet;
 	socket_core_ref socket;
@@ -884,4 +908,5 @@
 	int listening_socket_id = listening_socket->socket_id;
 	int listening_port = listening_socket->port;
+	int rc;
 
 	assert(listening_socket);
@@ -913,19 +938,20 @@
 	memcpy(socket_data->addr, src, socket_data->addrlen);
 	socket_data->dest_port = ntohs(header->source_port);
-	if (ERROR_OCCURRED(tl_set_address_port(socket_data->addr,
-	    socket_data->addrlen, socket_data->dest_port))) {
+	rc = tl_set_address_port(socket_data->addr, socket_data->addrlen,
+	    socket_data->dest_port);
+	if (rc != EOK) {
 		free(socket_data->addr);
 		free(socket_data);
-		pq_release_remote(tcp_globals.net_phone, packet_get_id(packet));
-		return ERROR_CODE;
+		return tcp_release_and_return(packet, rc);
 	}
 
 	// create a socket
 	socket_id = -1;
-	if (ERROR_OCCURRED(socket_create(socket_data->local_sockets,
-	    listening_socket->phone, socket_data, &socket_id))) {
+	rc = socket_create(socket_data->local_sockets, listening_socket->phone,
+	    socket_data, &socket_id);
+	if (rc != EOK) {
 		free(socket_data->addr);
 		free(socket_data);
-		return tcp_release_and_return(packet, ERROR_CODE);
+		return tcp_release_and_return(packet, rc);
 	}
 
@@ -964,19 +990,19 @@
 	assert(socket_data);
 
-	ERROR_CODE = socket_port_add(&tcp_globals.sockets, listening_port,
-	    socket, (const char *) socket_data->addr, socket_data->addrlen);
+	rc = socket_port_add(&tcp_globals.sockets, listening_port, socket,
+	    (const char *) socket_data->addr, socket_data->addrlen);
 	assert(socket == socket_port_find(&tcp_globals.sockets, listening_port,
 	    (const char *) socket_data->addr, socket_data->addrlen));
 
-//	ERROR_CODE = socket_bind_free_port(&tcp_globals.sockets, socket,
+//	rc = socket_bind_free_port(&tcp_globals.sockets, socket,
 //	    TCP_FREE_PORTS_START, TCP_FREE_PORTS_END,
 //	    tcp_globals.last_used_port);
 //	tcp_globals.last_used_port = socket->port;
 	fibril_rwlock_write_unlock(&tcp_globals.lock);
-	if (ERROR_CODE != EOK) {
+	if (rc != EOK) {
 		socket_destroy(tcp_globals.net_phone, socket->socket_id,
 		    socket_data->local_sockets, &tcp_globals.sockets,
 		    tcp_free_socket_data);
-		return tcp_release_and_return(packet, ERROR_CODE);
+		return tcp_release_and_return(packet, rc);
 	}
 
@@ -992,20 +1018,23 @@
 
 	// trim if longer than the header
-	if ((packet_get_data_length(packet) > sizeof(*header)) &&
-	    ERROR_OCCURRED(packet_trim(packet, 0,
-	    packet_get_data_length(packet) - sizeof(*header)))) {
+	if (packet_get_data_length(packet) > sizeof(*header)) {
+		rc = packet_trim(packet, 0,
+		    packet_get_data_length(packet) - sizeof(*header));
+		if (rc != EOK) {
+			socket_destroy(tcp_globals.net_phone, socket->socket_id,
+			    socket_data->local_sockets, &tcp_globals.sockets,
+			    tcp_free_socket_data);
+			return tcp_release_and_return(packet, rc);
+		}
+	}
+
+	tcp_prepare_operation_header(socket, socket_data, header, 1, 0);
+
+	rc = tcp_queue_packet(socket, socket_data, packet, 1);
+	if (rc != EOK) {
 		socket_destroy(tcp_globals.net_phone, socket->socket_id,
 		    socket_data->local_sockets, &tcp_globals.sockets,
 		    tcp_free_socket_data);
-		return tcp_release_and_return(packet, ERROR_CODE);
-	}
-
-	tcp_prepare_operation_header(socket, socket_data, header, 1, 0);
-
-	if (ERROR_OCCURRED(tcp_queue_packet(socket, socket_data, packet, 1))) {
-		socket_destroy(tcp_globals.net_phone, socket->socket_id,
-		    socket_data->local_sockets, &tcp_globals.sockets,
-		    tcp_free_socket_data);
-		return ERROR_CODE;
+		return rc;
 	}
 
@@ -1031,8 +1060,7 @@
     tcp_socket_data_ref socket_data, tcp_header_ref header, packet_t packet)
 {
-	ERROR_DECLARE;
-
 	socket_core_ref listening_socket;
 	tcp_socket_data_ref listening_socket_data;
+	int rc;
 
 	assert(socket);
@@ -1059,8 +1087,7 @@
 
 		// queue the received packet
-		if (ERROR_NONE(dyn_fifo_push(&listening_socket->accepted,
-		    (-1 * socket->socket_id),
-		    listening_socket_data->backlog))) {
-
+		rc = dyn_fifo_push(&listening_socket->accepted,
+		    (-1 * socket->socket_id), listening_socket_data->backlog);
+		if (rc == EOK) {
 			// notify the destination socket
 			async_msg_5(socket->phone, NET_SOCKET_ACCEPTED,
@@ -1077,9 +1104,12 @@
 
 	// create the notification packet
-	ERROR_PROPAGATE(tcp_create_notification_packet(&packet, socket,
-	    socket_data, 0, 1));
+	rc = tcp_create_notification_packet(&packet, socket, socket_data, 0, 1);
+	if (rc != EOK)
+		return rc;
 
 	// send the packet
-	ERROR_PROPAGATE(tcp_queue_packet(socket, socket_data, packet, 1));
+	rc = tcp_queue_packet(socket, socket_data, packet, 1);
+	if (rc != EOK)
+		return rc;
 
 	// flush packets
@@ -1198,7 +1228,6 @@
     ipc_call_t *answer, int *answer_count)
 {
-	ERROR_DECLARE;
-
 	packet_t packet;
+	int rc;
 
 	assert(call);
@@ -1209,13 +1238,15 @@
 	switch (IPC_GET_METHOD(*call)) {
 	case NET_TL_RECEIVED:
-		//fibril_rwlock_read_lock(&tcp_globals.lock);
-		if (ERROR_NONE(packet_translate_remote(tcp_globals.net_phone,
-		    &packet, IPC_GET_PACKET(call)))) {
-			ERROR_CODE = tcp_received_msg(IPC_GET_DEVICE(call),
-			    packet, SERVICE_TCP, IPC_GET_ERROR(call));
-		}
-		//fibril_rwlock_read_unlock(&tcp_globals.lock);
-		return ERROR_CODE;
-
+//		fibril_rwlock_read_lock(&tcp_globals.lock);
+		rc = packet_translate_remote(tcp_globals.net_phone, &packet,
+		    IPC_GET_PACKET(call));
+		if (rc != EOK) {
+//			fibril_rwlock_read_unlock(&tcp_globals.lock);
+			return rc;
+		}
+		rc = tcp_received_msg(IPC_GET_DEVICE(call), packet, SERVICE_TCP,
+		    IPC_GET_ERROR(call));
+//		fibril_rwlock_read_unlock(&tcp_globals.lock);
+		return rc;
 	case IPC_M_CONNECT_TO_ME:
 		return tcp_process_client_messages(callid, *call);
@@ -1662,7 +1693,6 @@
     struct sockaddr *addr, socklen_t addrlen)
 {
-	ERROR_DECLARE;
-
 	socket_core_ref socket;
+	int rc;
 
 	assert(local_sockets);
@@ -1675,6 +1705,6 @@
 		return ENOTSOCK;
 	
-	if (ERROR_OCCURRED(tcp_connect_core(socket, local_sockets, addr,
-	    addrlen))) {
+	rc = tcp_connect_core(socket, local_sockets, addr, addrlen);
+	if (rc != EOK) {
 		tcp_free_socket_data(socket);
 		// unbind if bound
@@ -1685,5 +1715,5 @@
 		}
 	}
-	return ERROR_CODE;
+	return rc;
 }
 
@@ -1692,8 +1722,7 @@
     struct sockaddr *addr, socklen_t addrlen)
 {
-	ERROR_DECLARE;
-
 	tcp_socket_data_ref socket_data;
 	packet_t packet;
+	int rc;
 
 	assert(socket);
@@ -1711,22 +1740,29 @@
 
 	// get the destination port
-	ERROR_PROPAGATE(tl_get_address_port(addr, addrlen,
-	    &socket_data->dest_port));
+	rc = tl_get_address_port(addr, addrlen, &socket_data->dest_port);
+	if (rc != EOK)
+		return rc;
+	
 	if (socket->port <= 0) {
 		// try to find a free port
-		ERROR_PROPAGATE(socket_bind_free_port(&tcp_globals.sockets,
-		    socket, TCP_FREE_PORTS_START, TCP_FREE_PORTS_END,
-		    tcp_globals.last_used_port));
+		rc = socket_bind_free_port(&tcp_globals.sockets, socket,
+		    TCP_FREE_PORTS_START, TCP_FREE_PORTS_END,
+		    tcp_globals.last_used_port);
+		if (rc != EOK)
+			return rc;
 		// set the next port as the search starting port number
 		tcp_globals.last_used_port = socket->port;
 	}
 
-	ERROR_PROPAGATE(ip_get_route_req(tcp_globals.ip_phone, IPPROTO_TCP,
+	rc = ip_get_route_req(tcp_globals.ip_phone, IPPROTO_TCP,
 	    addr, addrlen, &socket_data->device_id,
-	    &socket_data->pseudo_header, &socket_data->headerlen));
+	    &socket_data->pseudo_header, &socket_data->headerlen);
+	if (rc != EOK)
+		return rc;
 
 	// create the notification packet
-	ERROR_PROPAGATE(tcp_create_notification_packet(&packet, socket,
-	    socket_data, 1, 0));
+	rc = tcp_create_notification_packet(&packet, socket, socket_data, 1, 0);
+	if (rc != EOK)
+		return rc;
 
 	// unlock the globals and wait for an operation
@@ -1736,7 +1772,9 @@
 	socket_data->addrlen = addrlen;
 	// send the packet
-	if (ERROR_OCCURRED(tcp_queue_packet(socket, socket_data, packet, 1)) ||
-	    ERROR_OCCURRED(tcp_prepare_timeout(tcp_timeout, socket, socket_data,
-	    0, TCP_SOCKET_INITIAL, NET_DEFAULT_TCP_INITIAL_TIMEOUT, false))) {
+
+	if (((rc = tcp_queue_packet(socket, socket_data, packet, 1)) != EOK) ||
+	    ((rc = tcp_prepare_timeout(tcp_timeout, socket, socket_data, 0,
+	    TCP_SOCKET_INITIAL, NET_DEFAULT_TCP_INITIAL_TIMEOUT, false)) !=
+	    EOK)) {
 		socket_data->addr = NULL;
 		socket_data->addrlen = 0;
@@ -1754,6 +1792,6 @@
 			fibril_condvar_wait(&socket_data->operation.condvar,
 			    &socket_data->operation.mutex);
-			ERROR_CODE = socket_data->operation.result;
-			if (ERROR_CODE != EOK) {
+			rc = socket_data->operation.result;
+			if (rc != EOK) {
 				socket_data->addr = NULL;
 				socket_data->addrlen = 0;
@@ -1762,5 +1800,5 @@
 			socket_data->addr = NULL;
 			socket_data->addrlen = 0;
-			ERROR_CODE = EINTR;
+			rc = EINTR;
 		}
 	}
@@ -1769,5 +1807,5 @@
 
 	// return the result
-	return ERROR_CODE;
+	return rc;
 }
 
@@ -1776,7 +1814,6 @@
     tcp_socket_data_ref socket_data, packet_t packet, size_t data_length)
 {
-	ERROR_DECLARE;
-
 	tcp_header_ref header;
+	int rc;
 
 	assert(socket);
@@ -1793,6 +1830,7 @@
 	header->sequence_number = htonl(socket_data->next_outgoing);
 
-	if (ERROR_OCCURRED(packet_set_addr(packet, NULL,
-	    (uint8_t *) socket_data->addr, socket_data->addrlen)))
+	rc = packet_set_addr(packet, NULL, (uint8_t *) socket_data->addr,
+	    socket_data->addrlen);
+	if (rc != EOK)
 		return tcp_release_and_return(packet, EINVAL);
 
@@ -1808,5 +1846,5 @@
     packet_t packet, size_t data_length)
 {
-	ERROR_DECLARE;
+	int rc;
 
 	assert(socket);
@@ -1814,10 +1852,12 @@
 	assert(socket->specific_data == socket_data);
 
-	ERROR_PROPAGATE(tcp_queue_prepare_packet(socket, socket_data, packet,
-	    data_length));
-
-	if (ERROR_OCCURRED(pq_add(&socket_data->outgoing, packet,
-	    socket_data->next_outgoing, data_length)))
-		return tcp_release_and_return(packet, ERROR_CODE);
+	rc = tcp_queue_prepare_packet(socket, socket_data, packet, data_length);
+	if (rc != EOK)
+		return rc;
+
+	rc = pq_add(&socket_data->outgoing, packet, socket_data->next_outgoing,
+	    data_length);
+	if (rc != EOK)
+		return tcp_release_and_return(packet, rc);
 
 	socket_data->next_outgoing += data_length;
@@ -1828,6 +1868,4 @@
 tcp_get_packets_to_send(socket_core_ref socket, tcp_socket_data_ref socket_data)
 {
-	ERROR_DECLARE;
-
 	packet_t packet;
 	packet_t copy;
@@ -1835,4 +1873,5 @@
 	packet_t previous = NULL;
 	size_t data_length;
+	int rc;
 
 	assert(socket);
@@ -1859,8 +1898,11 @@
 		if (!sending) {
 			sending = copy;
-		} else if (ERROR_OCCURRED(pq_insert_after(previous, copy))) {
-			pq_release_remote(tcp_globals.net_phone,
-			    packet_get_id(copy));
-			return sending;
+		} else {
+			rc = pq_insert_after(previous, copy);
+			if (rc != EOK) {
+				pq_release_remote(tcp_globals.net_phone,
+				    packet_get_id(copy));
+				return sending;
+			}
 		}
 
@@ -1884,8 +1926,7 @@
     packet_t packet, size_t data_length, size_t sequence_number)
 {
-	ERROR_DECLARE;
-
 	tcp_header_ref header;
 	uint32_t checksum;
+	int rc;
 
 	assert(socket);
@@ -1894,7 +1935,7 @@
 
 	// adjust the pseudo header
-	if (ERROR_OCCURRED(ip_client_set_pseudo_header_data_length(
-	    socket_data->pseudo_header, socket_data->headerlen,
-	    packet_get_data_length(packet)))) {
+	rc = ip_client_set_pseudo_header_data_length(socket_data->pseudo_header,
+	    socket_data->headerlen, packet_get_data_length(packet));
+	if (rc != EOK) {
 		pq_release_remote(tcp_globals.net_phone, packet_get_id(packet));
 		return NULL;
@@ -1921,13 +1962,18 @@
 	checksum = compute_checksum(0, socket_data->pseudo_header,
 	    socket_data->headerlen);
-	checksum = compute_checksum(checksum, (uint8_t *) packet_get_data(packet),
+	checksum = compute_checksum(checksum,
+	    (uint8_t *) packet_get_data(packet),
 	    packet_get_data_length(packet));
 	header->checksum = htons(flip_checksum(compact_checksum(checksum)));
 
 	// prepare the packet
-	if (ERROR_OCCURRED(ip_client_prepare_packet(packet, IPPROTO_TCP, 0, 0,
-	    0, 0)) || ERROR_OCCURRED(tcp_prepare_timeout(tcp_timeout, socket,
-	    socket_data, sequence_number, socket_data->state,
-	    socket_data->timeout, true))) {
+	rc = ip_client_prepare_packet(packet, IPPROTO_TCP, 0, 0, 0, 0);
+	if (rc != EOK) {
+		pq_release_remote(tcp_globals.net_phone, packet_get_id(packet));
+		return NULL;
+	}
+	rc = tcp_prepare_timeout(tcp_timeout, socket, socket_data,
+	    sequence_number, socket_data->state, socket_data->timeout, true);
+	if (rc != EOK) {
 		pq_release_remote(tcp_globals.net_phone, packet_get_id(packet));
 		return NULL;
@@ -2038,6 +2084,4 @@
     size_t *addrlen)
 {
-	ERROR_DECLARE;
-
 	socket_core_ref socket;
 	tcp_socket_data_ref socket_data;
@@ -2045,4 +2089,5 @@
 	packet_t packet;
 	size_t length;
+	int rc;
 
 	assert(local_sockets);
@@ -2066,6 +2111,7 @@
 	// send the source address if desired
 	if (addrlen) {
-		ERROR_PROPAGATE(data_reply(socket_data->addr,
-		    socket_data->addrlen));
+		rc = data_reply(socket_data->addr, socket_data->addrlen);
+		if (rc != EOK)
+			return rc;
 		*addrlen = socket_data->addrlen;
 	}
@@ -2076,9 +2122,12 @@
 		return NO_DATA;
 
-	ERROR_PROPAGATE(packet_translate_remote(tcp_globals.net_phone, &packet,
-	    packet_id));
+	rc = packet_translate_remote(tcp_globals.net_phone, &packet, packet_id);
+	if (rc != EOK)
+		return rc;
 
 	// reply the packets
-	ERROR_PROPAGATE(socket_reply_packets(packet, &length));
+	rc = socket_reply_packets(packet, &length);
+	if (rc != EOK)
+		return rc;
 
 	// release the packet
@@ -2093,6 +2142,4 @@
     size_t *data_fragment_size, int flags)
 {
-	ERROR_DECLARE;
-
 	socket_core_ref socket;
 	tcp_socket_data_ref socket_data;
@@ -2103,4 +2150,5 @@
 	int index;
 	int result;
+	int rc;
 
 	assert(local_sockets);
@@ -2123,6 +2171,8 @@
 		return ENOTCONN;
 
-	ERROR_PROPAGATE(tl_get_ip_packet_dimension(tcp_globals.ip_phone,
-	   &tcp_globals.dimensions, socket_data->device_id, &packet_dimension));
+	rc = tl_get_ip_packet_dimension(tcp_globals.ip_phone,
+	    &tcp_globals.dimensions, socket_data->device_id, &packet_dimension);
+	if (rc != EOK)
+		return rc;
 
 	*data_fragment_size =
@@ -2145,6 +2195,7 @@
 
 		tcp_prepare_operation_header(socket, socket_data, header, 0, 0);
-		ERROR_PROPAGATE(tcp_queue_packet(socket, socket_data, packet,
-		    0));
+		rc = tcp_queue_packet(socket, socket_data, packet, 0);
+		if (rc != EOK)
+			return rc;
 	}
 
@@ -2165,9 +2216,8 @@
 tcp_close_message(socket_cores_ref local_sockets, int socket_id)
 {
-	ERROR_DECLARE;
-
 	socket_core_ref socket;
 	tcp_socket_data_ref socket_data;
 	packet_t packet;
+	int rc;
 
 	// find the socket
@@ -2194,11 +2244,12 @@
 	default:
 		// just destroy
-		if (ERROR_NONE(socket_destroy(tcp_globals.net_phone, socket_id,
+		rc = socket_destroy(tcp_globals.net_phone, socket_id,
 		    local_sockets, &tcp_globals.sockets,
-		    tcp_free_socket_data))) {
+		    tcp_free_socket_data);
+		if (rc == EOK) {
 			fibril_rwlock_write_unlock(socket_data->local_lock);
 			fibril_rwlock_write_unlock(&tcp_globals.lock);
 		}
-		return ERROR_CODE;
+		return rc;
 	}
 
@@ -2207,9 +2258,12 @@
 
 	// create the notification packet
-	ERROR_PROPAGATE(tcp_create_notification_packet(&packet, socket,
-	    socket_data, 0, 1));
+	rc = tcp_create_notification_packet(&packet, socket, socket_data, 0, 1);
+	if (rc != EOK)
+		return rc;
 
 	// send the packet
-	ERROR_PROPAGATE(tcp_queue_packet(socket, socket_data, packet, 1));
+	rc = tcp_queue_packet(socket, socket_data, packet, 1);
+	if (rc != EOK)
+		return rc;
 
 	// flush packets
@@ -2230,15 +2284,15 @@
     tcp_socket_data_ref socket_data, int synchronize, int finalize)
 {
-	ERROR_DECLARE;
-
 	packet_dimension_ref packet_dimension;
 	tcp_header_ref header;
+	int rc;
 
 	assert(packet);
 
 	// get the device packet dimension
-	ERROR_PROPAGATE(tl_get_ip_packet_dimension(tcp_globals.ip_phone,
-	    &tcp_globals.dimensions, socket_data->device_id,
-	    &packet_dimension));
+	rc = tl_get_ip_packet_dimension(tcp_globals.ip_phone,
+	    &tcp_globals.dimensions, socket_data->device_id, &packet_dimension);
+	if (rc != EOK)
+		return rc;
 
 	// get a new packet
@@ -2265,10 +2319,9 @@
     int new_socket_id, size_t *data_fragment_size, size_t *addrlen)
 {
-	ERROR_DECLARE;
-
 	socket_core_ref accepted;
 	socket_core_ref socket;
 	tcp_socket_data_ref socket_data;
 	packet_dimension_ref packet_dimension;
+	int rc;
 
 	assert(local_sockets);
@@ -2304,9 +2357,13 @@
 		// TODO can it be in another state?
 		if (socket_data->state == TCP_SOCKET_ESTABLISHED) {
-			ERROR_PROPAGATE(data_reply(socket_data->addr,
-			    socket_data->addrlen));
-			ERROR_PROPAGATE(tl_get_ip_packet_dimension(
-			    tcp_globals.ip_phone, &tcp_globals.dimensions,
-			    socket_data->device_id, &packet_dimension));
+			rc = data_reply(socket_data->addr,
+			    socket_data->addrlen);
+			if (rc != EOK)
+				return rc;
+			rc = tl_get_ip_packet_dimension(tcp_globals.ip_phone,
+			    &tcp_globals.dimensions, socket_data->device_id,
+			    &packet_dimension);
+			if (rc != EOK)
+				return rc;
 			*addrlen = socket_data->addrlen;
 
@@ -2318,7 +2375,8 @@
 	
 			if (new_socket_id > 0) {
-				ERROR_PROPAGATE(socket_cores_update(
-				    local_sockets, accepted->socket_id,
-				    new_socket_id));
+				rc = socket_cores_update(local_sockets,
+				    accepted->socket_id, new_socket_id);
+				if (rc != EOK)
+					return rc;
 				accepted->socket_id = new_socket_id;
 			}
@@ -2430,13 +2488,8 @@
 main(int argc, char *argv[])
 {
-	ERROR_DECLARE;
-
-	/*
-	   Start the module 
-	 */
-	if (ERROR_OCCURRED(tl_module_start_standalone(tl_client_connection)))
-		return ERROR_CODE;
-
-	return EOK;
+	int rc;
+
+	rc = tl_module_start_standalone(tl_client_connection);
+	return rc;
 }
 
Index: uspace/srv/net/tl/tcp/tcp_module.c
===================================================================
--- uspace/srv/net/tl/tcp/tcp_module.c	(revision 0485135c4340bfe39246c5097af24c53043005de)
+++ uspace/srv/net/tl/tcp/tcp_module.c	(revision 0b81cad0360a509d54d5a8a7f64c14e5fb6f91e6)
@@ -44,5 +44,5 @@
 #include <async.h>
 #include <stdio.h>
-#include <err.h>
+#include <errno.h>
 #include <ipc/ipc.h>
 #include <ipc/services.h>
@@ -61,21 +61,27 @@
 int tl_module_start_standalone(async_client_conn_t client_connection)
 {
-	ERROR_DECLARE;
-	
+	ipcarg_t phonehash;
+	int rc;
+
 	async_set_client_connection(client_connection);
 	tcp_globals.net_phone = net_connect_module();
-	ERROR_PROPAGATE(pm_init());
-	
-	ipcarg_t phonehash;
-	if (ERROR_OCCURRED(tcp_initialize(client_connection)) ||
-	    ERROR_OCCURRED(REGISTER_ME(SERVICE_TCP, &phonehash))) {
-		pm_destroy();
-		return ERROR_CODE;
-	}
+
+	rc = pm_init();
+	if (rc != EOK)
+		return rc;
+
+	rc = tcp_initialize(client_connection);
+	if (rc != EOK)
+		goto out;
+
+	rc = REGISTER_ME(SERVICE_TCP, &phonehash);
+	if (rc != EOK)
+		goto out;
 	
 	async_manager();
 	
+out:
 	pm_destroy();
-	return EOK;
+	return rc;
 }
 
Index: uspace/srv/net/tl/udp/udp.c
===================================================================
--- uspace/srv/net/tl/udp/udp.c	(revision 0485135c4340bfe39246c5097af24c53043005de)
+++ uspace/srv/net/tl/udp/udp.c	(revision 0b81cad0360a509d54d5a8a7f64c14e5fb6f91e6)
@@ -51,5 +51,4 @@
 #include <adt/dynamic_fifo.h>
 #include <errno.h>
-#include <err.h>
 
 #include <net/socket_codes.h>
@@ -103,6 +102,4 @@
 int udp_initialize(async_client_conn_t client_connection)
 {
-	ERROR_DECLARE;
-
 	measured_string_t names[] = {
 		{
@@ -118,4 +115,5 @@
 	size_t count = sizeof(names) / sizeof(measured_string_t);
 	char *data;
+	int rc;
 
 	fibril_rwlock_initialize(&udp_globals.lock);
@@ -124,18 +122,33 @@
 	udp_globals.icmp_phone = icmp_connect_module(SERVICE_ICMP,
 	    ICMP_CONNECT_TIMEOUT);
+	
 	udp_globals.ip_phone = ip_bind_service(SERVICE_IP, IPPROTO_UDP,
 	    SERVICE_UDP, client_connection);
-	if (udp_globals.ip_phone < 0)
+	if (udp_globals.ip_phone < 0) {
+		fibril_rwlock_write_unlock(&udp_globals.lock);
 		return udp_globals.ip_phone;
+	}
 
 	// read default packet dimensions
-	ERROR_PROPAGATE(ip_packet_size_req(udp_globals.ip_phone, -1,
-	    &udp_globals.packet_dimension));
-	ERROR_PROPAGATE(socket_ports_initialize(&udp_globals.sockets));
-	if (ERROR_OCCURRED(packet_dimensions_initialize(
-	    &udp_globals.dimensions))) {
+	rc = ip_packet_size_req(udp_globals.ip_phone, -1,
+	    &udp_globals.packet_dimension);
+	if (rc != EOK) {
+		fibril_rwlock_write_unlock(&udp_globals.lock);
+		return rc;
+	}
+	
+	rc = socket_ports_initialize(&udp_globals.sockets);
+	if (rc != EOK) {
+		fibril_rwlock_write_unlock(&udp_globals.lock);
+		return rc;
+	}
+	
+	rc = packet_dimensions_initialize(&udp_globals.dimensions);
+	if (rc != EOK) {
 		socket_ports_destroy(&udp_globals.sockets);
-		return ERROR_CODE;
-	}
+		fibril_rwlock_write_unlock(&udp_globals.lock);
+		return rc;
+	}
+	
 	udp_globals.packet_dimension.prefix += sizeof(udp_header_t);
 	udp_globals.packet_dimension.content -= sizeof(udp_header_t);
@@ -147,6 +160,12 @@
 	// get configuration
 	configuration = &names[0];
-	ERROR_PROPAGATE(net_get_conf_req(udp_globals.net_phone, &configuration,
-	    count, &data));
+	rc = net_get_conf_req(udp_globals.net_phone, &configuration, count,
+	    &data);
+	if (rc != EOK) {
+		socket_ports_destroy(&udp_globals.sockets);
+		fibril_rwlock_write_unlock(&udp_globals.lock);
+		return rc;
+	}
+	
 	if (configuration) {
 		if (configuration[0].value)
@@ -201,6 +220,4 @@
 udp_process_packet(device_id_t device_id, packet_t packet, services_t error)
 {
-	ERROR_DECLARE;
-
 	size_t length;
 	size_t offset;
@@ -219,4 +236,5 @@
 	struct sockaddr *dest;
 	packet_dimension_ref packet_dimension;
+	int rc;
 
 	switch (error) {
@@ -232,7 +250,7 @@
 			return udp_release_and_return(packet, result);
 		length = (size_t) result;
-		if (ERROR_OCCURRED(packet_trim(packet, length, 0)))
-			return udp_release_and_return(packet,
-			    ERROR_CODE);
+		rc = packet_trim(packet, length, 0);
+		if (rc != EOK)
+			return udp_release_and_return(packet, rc);
 		break;
 	default:
@@ -253,6 +271,7 @@
 
 	// trim all but UDP header
-	if (ERROR_OCCURRED(packet_trim(packet, offset, 0)))
-		return udp_release_and_return(packet, ERROR_CODE);
+	rc = packet_trim(packet, offset, 0);
+	if (rc != EOK)
+		return udp_release_and_return(packet, rc);
 
 	// get udp header
@@ -284,9 +303,9 @@
 		if (result <= 0)
 			return udp_release_and_return(packet, result);
-
-		if (ERROR_OCCURRED(ip_client_get_pseudo_header(IPPROTO_UDP,
-		    src, result, dest, result, total_length, &ip_header,
-		    &length))) {
-			return udp_release_and_return(packet, ERROR_CODE);
+		
+		rc = ip_client_get_pseudo_header(IPPROTO_UDP, src, result, dest,
+		    result, total_length, &ip_header, &length);
+		if (rc != EOK) {
+			return udp_release_and_return(packet, rc);
 		} else {
 			checksum = compute_checksum(0, ip_header, length);
@@ -307,9 +326,7 @@
 
 		if (total_length < length) {
-			if (ERROR_OCCURRED(packet_trim(next_packet, 0,
-			    length - total_length))) {
-				return udp_release_and_return(packet,
-				    ERROR_CODE);
-			}
+			rc = packet_trim(next_packet, 0, length - total_length);
+			if (rc != EOK)
+				return udp_release_and_return(packet, rc);
 
 			// add partial checksum if set
@@ -360,10 +377,13 @@
 
 	// queue the received packet
-	if (ERROR_OCCURRED(dyn_fifo_push(&socket->received,
-	    packet_get_id(packet), SOCKET_MAX_RECEIVED_SIZE)) ||
-	    ERROR_OCCURRED(tl_get_ip_packet_dimension(udp_globals.ip_phone,
-	    &udp_globals.dimensions, device_id, &packet_dimension))) {
-		return udp_release_and_return(packet, ERROR_CODE);
-	}
+	rc = dyn_fifo_push(&socket->received, packet_get_id(packet),
+	    SOCKET_MAX_RECEIVED_SIZE);
+	if (rc != EOK)
+		return udp_release_and_return(packet, rc);
+		
+	rc = tl_get_ip_packet_dimension(udp_globals.ip_phone,
+	    &udp_globals.dimensions, device_id, &packet_dimension);
+	if (rc != EOK)
+		return udp_release_and_return(packet, rc);
 
 	// notify the destination socket
@@ -436,6 +456,4 @@
     size_t *data_fragment_size, int flags)
 {
-	ERROR_DECLARE;
-
 	socket_core_ref socket;
 	packet_t packet;
@@ -451,6 +469,9 @@
 	device_id_t device_id;
 	packet_dimension_ref packet_dimension;
-
-	ERROR_PROPAGATE(tl_get_address_port(addr, addrlen, &dest_port));
+	int rc;
+	
+	rc = tl_get_address_port(addr, addrlen, &dest_port);
+	if (rc != EOK)
+		return rc;
 
 	socket = socket_cores_find(local_sockets, socket_id);
@@ -460,44 +481,30 @@
 	if ((socket->port <= 0) && udp_globals.autobinding) {
 		// bind the socket to a random free port if not bound
-//		do {
-			// try to find a free port
-//			fibril_rwlock_read_unlock(&udp_globals.lock);
-//			fibril_rwlock_write_lock(&udp_globals.lock);
-			// might be changed in the meantime
-//			if (socket->port <= 0) {
-				if (ERROR_OCCURRED(socket_bind_free_port(
-				    &udp_globals.sockets, socket,
-				    UDP_FREE_PORTS_START, UDP_FREE_PORTS_END,
-				    udp_globals.last_used_port))) {
-//					fibril_rwlock_write_unlock(
-//					    &udp_globals.lock);
-//					fibril_rwlock_read_lock(
-//					    &udp_globals.lock);
-					return ERROR_CODE;
-				}
-				// set the next port as the search starting port
-				// number
-				udp_globals.last_used_port = socket->port;
-//			}
-//			fibril_rwlock_write_unlock(&udp_globals.lock);
-//			fibril_rwlock_read_lock(&udp_globals.lock);
-			// might be changed in the meantime
-//		} while (socket->port <= 0);
+		rc = socket_bind_free_port(&udp_globals.sockets, socket,
+		    UDP_FREE_PORTS_START, UDP_FREE_PORTS_END,
+		    udp_globals.last_used_port);
+		if (rc != EOK)
+			return rc;
+		// set the next port as the search starting port number
+		udp_globals.last_used_port = socket->port;
 	}
 
 	if (udp_globals.checksum_computing) {
-		if (ERROR_OCCURRED(ip_get_route_req(udp_globals.ip_phone,
-		    IPPROTO_UDP, addr, addrlen, &device_id, &ip_header,
-		    &headerlen))) {
-			return udp_release_and_return(packet, ERROR_CODE);
-		}
+		rc = ip_get_route_req(udp_globals.ip_phone, IPPROTO_UDP, addr,
+		    addrlen, &device_id, &ip_header, &headerlen);
+		if (rc != EOK)
+			return rc;
 		// get the device packet dimension
-//		ERROR_PROPAGATE(tl_get_ip_packet_dimension(udp_globals.ip_phone,
-//		    &udp_globals.dimensions, device_id, &packet_dimension));
+//		rc = tl_get_ip_packet_dimension(udp_globals.ip_phone,
+//		    &udp_globals.dimensions, device_id, &packet_dimension);
+//		if (rc != EOK)
+//			return rc;
 	}
 //	} else {
 		// do not ask all the time
-		ERROR_PROPAGATE(ip_packet_size_req(udp_globals.ip_phone, -1,
-		    &udp_globals.packet_dimension));
+		rc = ip_packet_size_req(udp_globals.ip_phone, -1,
+		    &udp_globals.packet_dimension);
+		if (rc != EOK)
+			return rc;
 		packet_dimension = &udp_globals.packet_dimension;
 //	}
@@ -529,6 +536,7 @@
 			return udp_release_and_return(packet, result);
 
-		if (ERROR_OCCURRED(pq_add(&packet, next_packet, index, 0)))
-			return udp_release_and_return(packet, ERROR_CODE);
+		rc = pq_add(&packet, next_packet, index, 0);
+		if (rc != EOK)
+			return udp_release_and_return(packet, rc);
 
 		total_length += (size_t) result;
@@ -547,8 +555,9 @@
 	if (udp_globals.checksum_computing) {
 		// update the pseudo header
-		if (ERROR_OCCURRED(ip_client_set_pseudo_header_data_length(
-		    ip_header, headerlen, total_length + UDP_HEADER_SIZE))) {
+		rc = ip_client_set_pseudo_header_data_length(ip_header,
+		    headerlen, total_length + UDP_HEADER_SIZE);
+		if (rc != EOK) {
 			free(ip_header);
-			return udp_release_and_return(packet, ERROR_CODE);
+			return udp_release_and_return(packet, rc);
 		}
 
@@ -565,11 +574,12 @@
 
 	// prepare the first packet fragment
-	if (ERROR_OCCURRED(ip_client_prepare_packet(packet, IPPROTO_UDP, 0, 0,
-	    0, 0))) {
-		return udp_release_and_return(packet, ERROR_CODE);
-	}
+	rc = ip_client_prepare_packet(packet, IPPROTO_UDP, 0, 0, 0, 0);
+	if (rc != EOK)
+		return udp_release_and_return(packet, rc);
+
+	/* Release the UDP global lock on success. */
+	fibril_rwlock_write_unlock(&udp_globals.lock);
 
 	// send the packet
-	fibril_rwlock_write_unlock(&udp_globals.lock);
 	ip_send_msg(udp_globals.ip_phone, device_id, packet, SERVICE_UDP, 0);
 
@@ -600,6 +610,4 @@
     size_t *addrlen)
 {
-	ERROR_DECLARE;
-
 	socket_core_ref socket;
 	int packet_id;
@@ -610,4 +618,5 @@
 	uint8_t *data;
 	int result;
+	int rc;
 
 	// find the socket
@@ -620,13 +629,16 @@
 	if (packet_id < 0)
 		return NO_DATA;
-
-	ERROR_PROPAGATE(packet_translate_remote(udp_globals.net_phone, &packet,
-	    packet_id));
+	
+	rc = packet_translate_remote(udp_globals.net_phone, &packet, packet_id);
+	if (rc != EOK) {
+		(void) dyn_fifo_pop(&socket->received);
+		return rc;
+	}
 
 	// get udp header
 	data = packet_get_data(packet);
 	if (!data) {
-		pq_release_remote(udp_globals.net_phone, packet_id);
-		return NO_DATA;
+		(void) dyn_fifo_pop(&socket->received);
+		return udp_release_and_return(packet, NO_DATA);
 	}
 	header = (udp_header_ref) data;
@@ -634,26 +646,46 @@
 	// set the source address port
 	result = packet_get_addr(packet, (uint8_t **) &addr, NULL);
-	if (ERROR_OCCURRED(tl_set_address_port(addr, result,
-	    ntohs(header->source_port)))) {
-		pq_release_remote(udp_globals.net_phone, packet_id);
-		return ERROR_CODE;
+	rc = tl_set_address_port(addr, result, ntohs(header->source_port));
+	if (rc != EOK) {
+		(void) dyn_fifo_pop(&socket->received);
+		return udp_release_and_return(packet, rc);
 	}
 	*addrlen = (size_t) result;
 
 	// send the source address
-	ERROR_PROPAGATE(data_reply(addr, *addrlen));
+	rc = data_reply(addr, *addrlen);
+	switch (rc) {
+	case EOK:
+		break;
+	case EOVERFLOW:
+		return rc;
+	default:
+		(void) dyn_fifo_pop(&socket->received);
+		return udp_release_and_return(packet, rc);
+	}
 
 	// trim the header
-	ERROR_PROPAGATE(packet_trim(packet, UDP_HEADER_SIZE, 0));
+	rc = packet_trim(packet, UDP_HEADER_SIZE, 0);
+	if (rc != EOK) {
+		(void) dyn_fifo_pop(&socket->received);
+		return udp_release_and_return(packet, rc);
+	}
 
 	// reply the packets
-	ERROR_PROPAGATE(socket_reply_packets(packet, &length));
-
-	// release the packet
-	dyn_fifo_pop(&socket->received);
-	pq_release_remote(udp_globals.net_phone, packet_get_id(packet));
-
-	// return the total length
-	return (int) length;
+	rc = socket_reply_packets(packet, &length);
+	switch (rc) {
+	case EOK:
+		break;
+	case EOVERFLOW:
+		return rc;
+	default:
+		(void) dyn_fifo_pop(&socket->received);
+		return udp_release_and_return(packet, rc);
+	}
+
+	(void) dyn_fifo_pop(&socket->received);
+
+	// release the packet and return the total length
+	return udp_release_and_return(packet, (int) length);
 }
 
@@ -826,7 +858,6 @@
     ipc_call_t *answer, int *answer_count)
 {
-	ERROR_DECLARE;
-
 	packet_t packet;
+	int rc;
 
 	*answer_count = 0;
@@ -834,11 +865,10 @@
 	switch (IPC_GET_METHOD(*call)) {
 	case NET_TL_RECEIVED:
-		if (ERROR_NONE(packet_translate_remote(udp_globals.net_phone,
-		    &packet, IPC_GET_PACKET(call)))) {
-			ERROR_CODE = udp_received_msg(IPC_GET_DEVICE(call),
-			    packet, SERVICE_UDP, IPC_GET_ERROR(call));
-		}
-		return ERROR_CODE;
-	
+		rc = packet_translate_remote(udp_globals.net_phone, &packet,
+		    IPC_GET_PACKET(call));
+		if (rc != EOK)
+			return rc;
+		return udp_received_msg(IPC_GET_DEVICE(call), packet,
+		    SERVICE_UDP, IPC_GET_ERROR(call));
 	case IPC_M_CONNECT_TO_ME:
 		return udp_process_client_messages(callid, * call);
@@ -850,7 +880,6 @@
 /** Default thread for new connections.
  *
- *  @param[in] iid	The initial message identifier.
- *  @param[in] icall	The initial message call structure.
- *
+ * @param[in] iid	The initial message identifier.
+ * @param[in] icall	The initial message call structure.
  */
 static void tl_client_connection(ipc_callid_t iid, ipc_call_t * icall)
@@ -898,11 +927,9 @@
 int main(int argc, char *argv[])
 {
-	ERROR_DECLARE;
+	int rc;
 	
 	/* Start the module */
-	if (ERROR_OCCURRED(tl_module_start_standalone(tl_client_connection)))
-		return ERROR_CODE;
-	
-	return EOK;
+	rc = tl_module_start_standalone(tl_client_connection);
+	return rc;
 }
 
Index: uspace/srv/net/tl/udp/udp_module.c
===================================================================
--- uspace/srv/net/tl/udp/udp_module.c	(revision 0485135c4340bfe39246c5097af24c53043005de)
+++ uspace/srv/net/tl/udp/udp_module.c	(revision 0b81cad0360a509d54d5a8a7f64c14e5fb6f91e6)
@@ -44,5 +44,5 @@
 #include <async.h>
 #include <stdio.h>
-#include <err.h>
+#include <errno.h>
 #include <ipc/ipc.h>
 #include <ipc/services.h>
@@ -59,7 +59,6 @@
 int tl_module_start_standalone(async_client_conn_t client_connection)
 {
-	ERROR_DECLARE;
-
 	ipcarg_t phonehash;
+	int rc;
 
 	async_set_client_connection(client_connection);
@@ -67,16 +66,22 @@
 	if (udp_globals.net_phone < 0)
 		return udp_globals.net_phone;
-
-	ERROR_PROPAGATE(pm_init());
-	if (ERROR_OCCURRED(udp_initialize(client_connection)) ||
-	    ERROR_OCCURRED(REGISTER_ME(SERVICE_UDP, &phonehash))) {
-		pm_destroy();
-		return ERROR_CODE;
-	}
+	
+	rc = pm_init();
+	if (rc != EOK)
+		return EOK;
+		
+	rc = udp_initialize(client_connection);
+	if (rc != EOK)
+		goto out;
+	
+	rc = REGISTER_ME(SERVICE_UDP, &phonehash);
+	if (rc != EOK)
+		goto out;
 
 	async_manager();
 
+out:
 	pm_destroy();
-	return EOK;
+	return rc;
 }
 
