Index: boot/arch/mips32/Makefile.inc
===================================================================
--- boot/arch/mips32/Makefile.inc	(revision bd29f9c90890870fd0eb33ada07cd91500b34157)
+++ boot/arch/mips32/Makefile.inc	(revision 542e819938a39bb45755f6bac4a0d7769c0ee65e)
@@ -29,5 +29,5 @@
 BFD_ARCH = mips
 BITS = 32
-EXTRA_CFLAGS = -mno-abicalls -G 0 -fno-zero-initialized-in-bss -mips3 -mabi=32
+EXTRA_CFLAGS = -msoft-float -mno-abicalls -G 0 -fno-zero-initialized-in-bss -mips3 -mabi=32
 
 RD_SRVS_NON_ESSENTIAL += \
@@ -48,5 +48,4 @@
 	BFD_OUTPUT = binary
 	ENDIANESS = LE
-	EXTRA_GCC_CFLAGS = -mhard-float
 endif
 
Index: boot/arch/mips64/Makefile.inc
===================================================================
--- boot/arch/mips64/Makefile.inc	(revision bd29f9c90890870fd0eb33ada07cd91500b34157)
+++ boot/arch/mips64/Makefile.inc	(revision 542e819938a39bb45755f6bac4a0d7769c0ee65e)
@@ -29,5 +29,5 @@
 BFD_ARCH = mips:4000
 BITS = 64
-EXTRA_CFLAGS = -mno-abicalls -G 0 -fno-zero-initialized-in-bss -mips3 -mabi=64
+EXTRA_CFLAGS = -msoft-float -mno-abicalls -G 0 -fno-zero-initialized-in-bss -mips3 -mabi=64
 
 ifeq ($(MACHINE),msim)
@@ -35,5 +35,4 @@
 	BFD_OUTPUT = binary
 	ENDIANESS = LE
-	EXTRA_GCC_CFLAGS = -mhard-float
 endif
 
Index: boot/generic/src/str.c
===================================================================
--- boot/generic/src/str.c	(revision bd29f9c90890870fd0eb33ada07cd91500b34157)
+++ boot/generic/src/str.c	(revision 542e819938a39bb45755f6bac4a0d7769c0ee65e)
@@ -357,13 +357,14 @@
  * and both strings consist of the same sequence of characters.
  *
- * A string is smaller than another string iff it is shorter or
- * has a character with lower value at the first position where
- * the strings differ.
+ * A string S1 is less than another string S2 if it has a character with
+ * lower value at the first character position where the strings differ.
+ * If the strings differ in length, the shorter one is treated as if
+ * padded by characters with a value of zero.
  *
  * @param s1 First string to compare.
  * @param s2 Second string to compare.
  *
- * @return 0 if the strings are equal, -1 if first is smaller,
- *         1 if second smaller.
+ * @return 0 if the strings are equal, -1 if the first is less than the second,
+ *         1 if the second is less than the first.
  *
  */
Index: contrib/arch/HelenOS.adl
===================================================================
--- contrib/arch/HelenOS.adl	(revision bd29f9c90890870fd0eb33ada07cd91500b34157)
+++ contrib/arch/HelenOS.adl	(revision 542e819938a39bb45755f6bac4a0d7769c0ee65e)
@@ -1,3 +1,3 @@
-system architecture HelenOS version 0.4.1 {
+system architecture HelenOS version 0.5.0 {
 	/* SPARTAN kernel */
 	inst kernel kernel;
Index: contrib/bazaar/bzreml/__init__.py
===================================================================
--- contrib/bazaar/bzreml/__init__.py	(revision bd29f9c90890870fd0eb33ada07cd91500b34157)
+++ contrib/bazaar/bzreml/__init__.py	(revision 542e819938a39bb45755f6bac4a0d7769c0ee65e)
@@ -102,8 +102,15 @@
 	return ""
 
+def iter_reverse_revision_history(repository, revision_id):
+	"""Iterate backwards through revision ids in the lefthand history"""
+	
+	graph = repository.get_graph()
+	stop_revisions = (None, _mod_revision.NULL_REVISION)
+	return graph.iter_lefthand_ancestry(revision_id, stop_revisions)
+
 def revision_sequence(branch, revision_old_id, revision_new_id):
 	"""Calculate a sequence of revisions"""
 	
-	for revision_ac_id in branch.repository.iter_reverse_revision_history(revision_new_id):
+	for revision_ac_id in iter_reverse_revision_history(branch.repository, revision_new_id):
 		if (revision_ac_id == revision_old_id):
 			break
Index: contrib/bazaar/mbprotect/__init__.py
===================================================================
--- contrib/bazaar/mbprotect/__init__.py	(revision bd29f9c90890870fd0eb33ada07cd91500b34157)
+++ contrib/bazaar/mbprotect/__init__.py	(revision 542e819938a39bb45755f6bac4a0d7769c0ee65e)
@@ -45,4 +45,11 @@
 from bzrlib.errors import TipChangeRejected
 
+def iter_reverse_revision_history(repository, revision_id):
+	"""Iterate backwards through revision ids in the lefthand history"""
+	
+	graph = repository.get_graph()
+	stop_revisions = (None, _mod_revision.NULL_REVISION)
+	return graph.iter_lefthand_ancestry(revision_id, stop_revisions)
+
 def pre_change_branch_tip(params):
 	repo = params.branch.repository
@@ -54,5 +61,5 @@
 	# First permitted case is appending changesets to main branch.Look for
 	# old tip in new main branch.
-	for revision_id in repo.iter_reverse_revision_history(params.new_revid):
+	for revision_id in iter_reverse_revision_history(repo, params.new_revid):
 		if revision_id == params.old_revid:
 			return	# Found old tip
@@ -60,5 +67,5 @@
 	# Another permitted case is backing out changesets. Look for new tip
 	# in old branch.
-	for revision_id in repo.iter_reverse_revision_history(params.old_revid):
+	for revision_id in iter_reverse_revision_history(repo, params.old_revid):
 		if revision_id == params.new_revid:
 			return	# Found new tip
Index: contrib/conf/mips32-gx.sh
===================================================================
--- contrib/conf/mips32-gx.sh	(revision bd29f9c90890870fd0eb33ada07cd91500b34157)
+++ contrib/conf/mips32-gx.sh	(revision 542e819938a39bb45755f6bac4a0d7769c0ee65e)
@@ -8,3 +8,10 @@
 fi
 
-gxemul $@ -E oldtestmips -C R4000 -X image.boot -d d0:"$DISK_IMG"
+if [ "$1" == "-E" ] && [ -n "$2" ]; then
+	MACHINE="$2"
+	shift 2
+else
+	MACHINE="oldtestmips"
+fi
+
+gxemul $@ -E "$MACHINE" -C R4000 -X image.boot -d d0:"$DISK_IMG"
Index: defaults/mips32/Makefile.config
===================================================================
--- defaults/mips32/Makefile.config	(revision bd29f9c90890870fd0eb33ada07cd91500b34157)
+++ defaults/mips32/Makefile.config	(revision 542e819938a39bb45755f6bac4a0d7769c0ee65e)
@@ -47,2 +47,4 @@
 CONFIG_MOUNT_DATA = n
 
+# Barebone build with essential binaries only 
+CONFIG_BAREBONE = y
Index: defaults/sparc64/ultra/Makefile.config
===================================================================
--- defaults/sparc64/ultra/Makefile.config	(revision bd29f9c90890870fd0eb33ada07cd91500b34157)
+++ defaults/sparc64/ultra/Makefile.config	(revision 542e819938a39bb45755f6bac4a0d7769c0ee65e)
@@ -4,2 +4,5 @@
 # CPU type
 PROCESSOR = us
+
+# Barebone build with essential binaries only
+CONFIG_BAREBONE = y
Index: kernel/arch/mips32/Makefile.inc
===================================================================
--- kernel/arch/mips32/Makefile.inc	(revision bd29f9c90890870fd0eb33ada07cd91500b34157)
+++ kernel/arch/mips32/Makefile.inc	(revision 542e819938a39bb45755f6bac4a0d7769c0ee65e)
@@ -29,5 +29,5 @@
 BFD_ARCH = mips
 BFD = binary
-GCC_CFLAGS += -mno-abicalls -G 0 -fno-zero-initialized-in-bss -mips3 -mabi=32
+GCC_CFLAGS += -msoft-float -mno-abicalls -G 0 -fno-zero-initialized-in-bss -mips3 -mabi=32
 
 BITS = 32
@@ -48,5 +48,4 @@
 	BFD_NAME = elf32-tradlittlemips
 	ENDIANESS = LE
-	GCC_CFLAGS += -mhard-float
 endif
 
Index: kernel/arch/mips64/Makefile.inc
===================================================================
--- kernel/arch/mips64/Makefile.inc	(revision bd29f9c90890870fd0eb33ada07cd91500b34157)
+++ kernel/arch/mips64/Makefile.inc	(revision 542e819938a39bb45755f6bac4a0d7769c0ee65e)
@@ -29,5 +29,5 @@
 BFD_ARCH = mips:4000
 BFD = binary
-GCC_CFLAGS += -mno-abicalls -G 0 -fno-zero-initialized-in-bss -mips3 -mabi=64
+GCC_CFLAGS += -msoft-float -mno-abicalls -G 0 -fno-zero-initialized-in-bss -mips3 -mabi=64
 AFLAGS = -64
 
@@ -40,5 +40,4 @@
 	BFD_NAME = elf64-tradlittlemips
 	ENDIANESS = LE
-	GCC_CFLAGS += -mhard-float
 endif
 
Index: kernel/generic/src/lib/str.c
===================================================================
--- kernel/generic/src/lib/str.c	(revision bd29f9c90890870fd0eb33ada07cd91500b34157)
+++ kernel/generic/src/lib/str.c	(revision 542e819938a39bb45755f6bac4a0d7769c0ee65e)
@@ -459,13 +459,14 @@
  * and both strings consist of the same sequence of characters.
  *
- * A string is smaller than another string iff it is shorter or
- * has a character with lower value at the first position where
- * the strings differ.
+ * A string S1 is less than another string S2 if it has a character with
+ * lower value at the first character position where the strings differ.
+ * If the strings differ in length, the shorter one is treated as if
+ * padded by characters with a value of zero.
  *
  * @param s1 First string to compare.
  * @param s2 Second string to compare.
  *
- * @return 0 if the strings are equal, -1 if first is smaller,
- *         1 if second smaller.
+ * @return 0 if the strings are equal, -1 if the first is less than the second,
+ *         1 if the second is less than the first.
  *
  */
@@ -503,7 +504,9 @@
  * up to max_len characters.
  *
- * A string is smaller than another string iff it is shorter or
- * has a character with lower value at the first position where
- * the strings differ, considering only first max_len characters.
+ * A string S1 is less than another string S2 if it has a character with
+ * lower value at the first character position where the strings differ.
+ * If the strings differ in length, the shorter one is treated as if
+ * padded by characters with a value of zero. Only the first max_len
+ * characters are considered.
  *
  * @param s1      First string to compare.
@@ -511,6 +514,6 @@
  * @param max_len Maximum number of characters to consider.
  *
- * @return 0 if the strings are equal, -1 if first is smaller,
- *         1 if second smaller.
+ * @return 0 if the strings are equal, -1 if the first is less than the second,
+ *         1 if the second is less than the first.
  *
  */
Index: release/Makefile
===================================================================
--- release/Makefile	(revision bd29f9c90890870fd0eb33ada07cd91500b34157)
+++ release/Makefile	(revision 542e819938a39bb45755f6bac4a0d7769c0ee65e)
@@ -33,5 +33,5 @@
 
 PROFILES = amd64 arm32/GXemul arm32/integratorcp arm32/gta02 ia32 \
-    ia64/i460GX ia64/ski mips32/GXemul mips32/msim sparc64/niagara \
+    ia64/i460GX ia64/ski mips32/GXemul mips32/msim ppc32 \
     sparc64/ultra
 
@@ -71,5 +71,5 @@
 release: src_rel
 	for profile in $(PROFILES); do \
-		$(MAKE) -C $(EXPORT_DIR) clean ; \
+		$(MAKE) -C $(EXPORT_DIR) distclean ; \
 		$(MAKE) -C $(EXPORT_DIR) PROFILE=$$profile ; \
 		$(MAKE) PROFILE=$$profile releasefile ; \
@@ -79,5 +79,5 @@
 	rm -rf $(EXPORT_DIR)
 	mkdir -p $(EXPORT_DIR)
-	$(BZR) export $(EXPORT_DIR)
+	$(BZR) export $(EXPORT_DIR) ../
 
 src_rel $(SRC_ARCHIVE): export
Index: uspace/lib/c/arch/abs32le/_link.ld.in
===================================================================
--- uspace/lib/c/arch/abs32le/_link.ld.in	(revision bd29f9c90890870fd0eb33ada07cd91500b34157)
+++ uspace/lib/c/arch/abs32le/_link.ld.in	(revision 542e819938a39bb45755f6bac4a0d7769c0ee65e)
@@ -22,4 +22,7 @@
 	. = 0x1000 + SIZEOF_HEADERS;
 #endif
+	
+	/* Make sure the code is aligned reasonably */
+	. = ALIGN(., 16);
 	
 	.text : {
Index: uspace/lib/c/arch/amd64/_link.ld.in
===================================================================
--- uspace/lib/c/arch/amd64/_link.ld.in	(revision bd29f9c90890870fd0eb33ada07cd91500b34157)
+++ uspace/lib/c/arch/amd64/_link.ld.in	(revision 542e819938a39bb45755f6bac4a0d7769c0ee65e)
@@ -23,4 +23,7 @@
 	. = 0x1000 + SIZEOF_HEADERS;
 #endif
+	
+	/* Make sure the code is aligned reasonably */
+	. = ALIGN(., 16);
 	
 	.init : {
Index: uspace/lib/c/arch/amd64/include/elf_linux.h
===================================================================
--- uspace/lib/c/arch/amd64/include/elf_linux.h	(revision bd29f9c90890870fd0eb33ada07cd91500b34157)
+++ uspace/lib/c/arch/amd64/include/elf_linux.h	(revision 542e819938a39bb45755f6bac4a0d7769c0ee65e)
@@ -66,4 +66,16 @@
 	uint64_t rsp;
 	uint64_t ss;
+
+	/*
+	 * The following registers need to be part of elf_regs_t.
+	 * Unfortunately, we don't have any information about them in our
+	 * istate_t.
+	 */
+	uint64_t unused_fs_base;
+	uint64_t unused_gs_base;
+	uint64_t unused_ds;
+	uint64_t unused_es;
+	uint64_t unused_fs;
+	uint64_t unused_gs;
 } elf_regs_t;
 
@@ -91,4 +103,14 @@
 	elf_regs->rsp = istate->rsp;
 	elf_regs->ss = istate->ss;
+
+	/*
+	 * Reset the registers for which there is not enough info in istate_t.
+	 */
+	elf_regs->unused_fs_base = 0;
+	elf_regs->unused_gs_base = 0;
+	elf_regs->unused_ds = 0;
+	elf_regs->unused_es = 0;
+	elf_regs->unused_fs = 0;
+	elf_regs->unused_gs = 0;
 }
 
Index: uspace/lib/c/arch/arm32/_link.ld.in
===================================================================
--- uspace/lib/c/arch/arm32/_link.ld.in	(revision bd29f9c90890870fd0eb33ada07cd91500b34157)
+++ uspace/lib/c/arch/arm32/_link.ld.in	(revision 542e819938a39bb45755f6bac4a0d7769c0ee65e)
@@ -22,4 +22,7 @@
 	. = 0x1000 + SIZEOF_HEADERS;
 #endif
+	
+	/* Make sure the code is aligned reasonably */
+	. = ALIGN(., 8);
 	
 	.init : {
Index: uspace/lib/c/arch/arm32/src/fibril.S
===================================================================
--- uspace/lib/c/arch/arm32/src/fibril.S	(revision bd29f9c90890870fd0eb33ada07cd91500b34157)
+++ uspace/lib/c/arch/arm32/src/fibril.S	(revision 542e819938a39bb45755f6bac4a0d7769c0ee65e)
@@ -35,5 +35,5 @@
 	stmia r0!, {sp, lr}
 	stmia r0!, {r4-r11}
-
+	
 	# return 1
 	mov r0, #1
@@ -43,6 +43,6 @@
 	ldmia r0!, {sp, lr}
 	ldmia r0!, {r4-r11}
-
-	#return 0
+	
+	# return 0
 	mov r0, #0
 	mov pc, lr
Index: uspace/lib/c/arch/arm32/src/stacktrace_asm.S
===================================================================
--- uspace/lib/c/arch/arm32/src/stacktrace_asm.S	(revision bd29f9c90890870fd0eb33ada07cd91500b34157)
+++ uspace/lib/c/arch/arm32/src/stacktrace_asm.S	(revision 542e819938a39bb45755f6bac4a0d7769c0ee65e)
@@ -41,4 +41,4 @@
 
 stacktrace_pc_get:
-	mov r0, lr 
+	mov r0, lr
 	mov pc, lr
Index: uspace/lib/c/arch/arm32/src/thread_entry.s
===================================================================
--- uspace/lib/c/arch/arm32/src/thread_entry.s	(revision bd29f9c90890870fd0eb33ada07cd91500b34157)
+++ uspace/lib/c/arch/arm32/src/thread_entry.s	(revision 542e819938a39bb45755f6bac4a0d7769c0ee65e)
@@ -42,4 +42,4 @@
 	push {fp, ip, lr, pc}
 	sub fp, ip, #4
-
-        b __thread_main
+	
+	b __thread_main
Index: uspace/lib/c/arch/ia32/_link.ld.in
===================================================================
--- uspace/lib/c/arch/ia32/_link.ld.in	(revision bd29f9c90890870fd0eb33ada07cd91500b34157)
+++ uspace/lib/c/arch/ia32/_link.ld.in	(revision 542e819938a39bb45755f6bac4a0d7769c0ee65e)
@@ -31,4 +31,7 @@
 #endif
 	
+	/* Make sure the code is aligned reasonably */
+	. = ALIGN(., 16);
+	
 	.init : {
 		*(.init);
@@ -39,5 +42,5 @@
 		*(.rodata .rodata.*);
 	} :text
-
+	
 #if defined(SHLIB) || defined(DLEXE)
 	.rel.plt : {
@@ -82,12 +85,13 @@
 #if defined(SHLIB) || defined(DLEXE)
 	.data.rel : {
-                *(.data.rel .data.rel.*);
+		*(.data.rel .data.rel.*);
 	} :data
-
+	
 	.got : {
-                *(.got);
+		*(.got);
 	} :data
+	
 	.got.plt : {
-                *(.got.plt);
+		*(.got.plt);
 	} :data
 #endif
Index: uspace/lib/c/arch/ia64/_link.ld.in
===================================================================
--- uspace/lib/c/arch/ia64/_link.ld.in	(revision bd29f9c90890870fd0eb33ada07cd91500b34157)
+++ uspace/lib/c/arch/ia64/_link.ld.in	(revision 542e819938a39bb45755f6bac4a0d7769c0ee65e)
@@ -23,8 +23,5 @@
 #endif
 	
-	/*
-	 * XXX This is just a work around. Problem: .init section does not
-	 * have the proper alignment.
-	 */
+	/* Make sure the code is aligned reasonably */
 	. = ALIGN(., 16);
 	
Index: uspace/lib/c/arch/mips32/Makefile.common
===================================================================
--- uspace/lib/c/arch/mips32/Makefile.common	(revision bd29f9c90890870fd0eb33ada07cd91500b34157)
+++ uspace/lib/c/arch/mips32/Makefile.common	(revision 542e819938a39bb45755f6bac4a0d7769c0ee65e)
@@ -27,5 +27,5 @@
 #
 
-GCC_CFLAGS += -mips3 -mabi=32
+GCC_CFLAGS += -msoft-float -mips3 -mabi=32
 
 ENDIANESS = LE
Index: uspace/lib/c/arch/mips32/_link.ld.in
===================================================================
--- uspace/lib/c/arch/mips32/_link.ld.in	(revision bd29f9c90890870fd0eb33ada07cd91500b34157)
+++ uspace/lib/c/arch/mips32/_link.ld.in	(revision 542e819938a39bb45755f6bac4a0d7769c0ee65e)
@@ -22,4 +22,7 @@
 	. = 0x4000 + SIZEOF_HEADERS;
 #endif
+	
+	/* Make sure the code is aligned reasonably */
+	. = ALIGN(., 16);
 	
 	.init : {
Index: uspace/lib/c/arch/mips32eb/Makefile.common
===================================================================
--- uspace/lib/c/arch/mips32eb/Makefile.common	(revision bd29f9c90890870fd0eb33ada07cd91500b34157)
+++ uspace/lib/c/arch/mips32eb/Makefile.common	(revision 542e819938a39bb45755f6bac4a0d7769c0ee65e)
@@ -27,5 +27,5 @@
 #
 
-GCC_CFLAGS += -mips3 -mabi=32
+GCC_CFLAGS += -msoft-float -mips3 -mabi=32
 
 ENDIANESS = BE
Index: uspace/lib/c/arch/mips64/Makefile.common
===================================================================
--- uspace/lib/c/arch/mips64/Makefile.common	(revision bd29f9c90890870fd0eb33ada07cd91500b34157)
+++ uspace/lib/c/arch/mips64/Makefile.common	(revision 542e819938a39bb45755f6bac4a0d7769c0ee65e)
@@ -27,5 +27,5 @@
 #
 
-GCC_CFLAGS += -mips3 -mabi=64
+GCC_CFLAGS += -msoft-float -mips3 -mabi=64
 AFLAGS = -64
 
Index: uspace/lib/c/arch/mips64/_link.ld.in
===================================================================
--- uspace/lib/c/arch/mips64/_link.ld.in	(revision bd29f9c90890870fd0eb33ada07cd91500b34157)
+++ uspace/lib/c/arch/mips64/_link.ld.in	(revision 542e819938a39bb45755f6bac4a0d7769c0ee65e)
@@ -23,4 +23,7 @@
 	. = 0x4000 + SIZEOF_HEADERS;
 #endif
+	
+	/* Make sure the code is aligned reasonably */
+	. = ALIGN(., 16);
 	
 	.init : {
Index: uspace/lib/c/arch/ppc32/_link.ld.in
===================================================================
--- uspace/lib/c/arch/ppc32/_link.ld.in	(revision bd29f9c90890870fd0eb33ada07cd91500b34157)
+++ uspace/lib/c/arch/ppc32/_link.ld.in	(revision 542e819938a39bb45755f6bac4a0d7769c0ee65e)
@@ -23,4 +23,7 @@
 	. = 0x1000 + SIZEOF_HEADERS;
 #endif
+	
+	/* Make sure the code is aligned reasonably */
+	. = ALIGN(., 4);
 	
 	.init : {
Index: uspace/lib/c/arch/sparc64/_link.ld.in
===================================================================
--- uspace/lib/c/arch/sparc64/_link.ld.in	(revision bd29f9c90890870fd0eb33ada07cd91500b34157)
+++ uspace/lib/c/arch/sparc64/_link.ld.in	(revision 542e819938a39bb45755f6bac4a0d7769c0ee65e)
@@ -22,4 +22,7 @@
 	. = 0x4000 + SIZEOF_HEADERS;
 #endif
+	
+	/* Make sure the code is aligned reasonably */
+	. = ALIGN(., 16);
 	
 	.init : {
Index: uspace/lib/c/generic/str.c
===================================================================
--- uspace/lib/c/generic/str.c	(revision bd29f9c90890870fd0eb33ada07cd91500b34157)
+++ uspace/lib/c/generic/str.c	(revision 542e819938a39bb45755f6bac4a0d7769c0ee65e)
@@ -431,13 +431,14 @@
  * and both strings consist of the same sequence of characters.
  *
- * A string is smaller than another string iff it is shorter or
- * has a character with lower value at the first position where
- * the strings differ.
+ * A string S1 is less than another string S2 if it has a character with
+ * lower value at the first character position where the strings differ.
+ * If the strings differ in length, the shorter one is treated as if
+ * padded by characters with a value of zero.
  *
  * @param s1 First string to compare.
  * @param s2 Second string to compare.
  *
- * @return 0 if the strings are equal, -1 if first is smaller,
- *         1 if second smaller.
+ * @return 0 if the strings are equal, -1 if the first is less than the second,
+ *         1 if the second is less than the first.
  *
  */
@@ -475,7 +476,9 @@
  * up to max_len characters.
  *
- * A string is smaller than another string iff it is shorter or
- * has a character with lower value at the first position where
- * the strings differ, considering only first max_len characters.
+ * A string S1 is less than another string S2 if it has a character with
+ * lower value at the first character position where the strings differ.
+ * If the strings differ in length, the shorter one is treated as if
+ * padded by characters with a value of zero. Only the first max_len
+ * characters are considered.
  *
  * @param s1      First string to compare.
@@ -483,6 +486,6 @@
  * @param max_len Maximum number of characters to consider.
  *
- * @return 0 if the strings are equal, -1 if first is smaller,
- *         1 if second smaller.
+ * @return 0 if the strings are equal, -1 if the first is less than the second,
+ *         1 if the second is less than the first.
  *
  */
Index: uspace/srv/net/tcp/sock.c
===================================================================
--- uspace/srv/net/tcp/sock.c	(revision bd29f9c90890870fd0eb33ada07cd91500b34157)
+++ uspace/srv/net/tcp/sock.c	(revision 542e819938a39bb45755f6bac4a0d7769c0ee65e)
@@ -779,4 +779,9 @@
 	}
 
+	/* Grab recv_buffer_lock because of CV wait in tcp_sock_recv_fibril() */
+	fibril_mutex_lock(&socket->recv_buffer_lock);
+	socket->sock_core = NULL;
+	fibril_mutex_unlock(&socket->recv_buffer_lock);
+
 	rc = socket_destroy(NULL, socket_id, &client->sockets, &gsock,
 	    tcp_free_sock_data);
@@ -839,8 +844,9 @@
 	log_msg(LVL_DEBUG, "tcp_sock_recv_fibril()");
 
+	fibril_mutex_lock(&sock->recv_buffer_lock);
+
 	while (true) {
 		log_msg(LVL_DEBUG, "call tcp_uc_receive()");
-		fibril_mutex_lock(&sock->recv_buffer_lock);
-		while (sock->recv_buffer_used != 0)
+		while (sock->recv_buffer_used != 0 && sock->sock_core != NULL)
 			fibril_condvar_wait(&sock->recv_buffer_cv,
 			    &sock->recv_buffer_lock);
@@ -852,6 +858,6 @@
 			sock->recv_error = trc;
 			fibril_condvar_broadcast(&sock->recv_buffer_cv);
-			fibril_mutex_unlock(&sock->recv_buffer_lock);
-			tcp_sock_notify_data(sock->sock_core);
+			if (sock->sock_core != NULL)
+				tcp_sock_notify_data(sock->sock_core);
 			break;
 		}
@@ -861,7 +867,9 @@
 		sock->recv_buffer_used = data_len;
 		fibril_condvar_broadcast(&sock->recv_buffer_cv);
-		fibril_mutex_unlock(&sock->recv_buffer_lock);
-		tcp_sock_notify_data(sock->sock_core);
-	}
+		if (sock->sock_core != NULL)
+			tcp_sock_notify_data(sock->sock_core);
+	}
+
+	fibril_mutex_unlock(&sock->recv_buffer_lock);
 
 	tcp_uc_delete(sock->conn);
Index: version
===================================================================
--- version	(revision bd29f9c90890870fd0eb33ada07cd91500b34157)
+++ version	(revision 542e819938a39bb45755f6bac4a0d7769c0ee65e)
@@ -36,6 +36,6 @@
 
 VERSION = 0
-PATCHLEVEL = 4
-SUBLEVEL = 3
+PATCHLEVEL = 5
+SUBLEVEL = 0
 
 ifdef EXTRAVERSION
@@ -45,4 +45,4 @@
 endif
 
-NAME = Sashimi
+NAME = Fajtl
 COPYRIGHT = Copyright (c) 2001-2012 HelenOS project
