Index: src/libcfa/heap.c
===================================================================
--- src/libcfa/heap.c	(revision a95c11749598f00148729214ecd78417a38fca57)
+++ src/libcfa/heap.c	(revision 0300979dcd79625c45973163a1e4c179b2303223)
@@ -10,6 +10,6 @@
 // Created On       : Tue Dec 19 21:58:35 2017
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Wed Jul 25 16:42:02 2018
-// Update Count     : 438
+// Last Modified On : Thu Jul 26 22:28:23 2018
+// Update Count     : 449
 // 
 
@@ -111,4 +111,32 @@
 // 	return temp;
 // } // prtHeapTermOff
+
+
+#ifdef __CFA_DEBUG__
+static unsigned int allocfree;							// running total of allocations minus frees
+static unsigned int appStart;							// storage allocation when application starts
+
+static void checkUnfreed() {
+	unsigned int total = allocfree - appStart;
+    if ( total != 0 ) {
+		// DO NOT USE STREAMS AS THEY MAY BE UNAVAILABLE AT THIS POINT.
+		// char helpText[512];
+		// int len = snprintf( helpText, 512, "CFA warning (UNIX pid:%ld) : program terminating with %u(0x%x) bytes of storage allocated but not freed.\n"
+		// 					"Possible cause is unfreed storage allocated by the program or system/library routines called from the program.\n",
+		// 					(long int)getpid(), total, total ); // always print the UNIX pid
+		// __cfaabi_dbg_bits_write( helpText, len );
+    } // if
+} // checkUnfreed
+
+extern "C" {
+void heapAppStart() {									// called by __cfaabi_appready_startup
+	appStart = allocfree;
+} // heapAppStart
+
+void heapAppStop() {									// called by __cfaabi_appready_startdown
+	checkUnfreed();
+} // heapAppStop
+} // extern "C"
+#endif // __CFA_DEBUG__
 
 
@@ -139,33 +167,4 @@
 static int mmapFd = -1;									// fake or actual fd for anonymous file
 
-static unsigned int allocfree;							// running total of allocations minus frees
-static unsigned int appStart;							// storage allocation when application starts
-
-static void checkUnfreed() {
-	#ifdef __CFA_DEBUG__
-	unsigned int total = allocfree - appStart;
-    if ( total != 0 ) {
-		// DO NOT USE STREAMS AS THEY MAY BE UNAVAILABLE AT THIS POINT.
-		// char helpText[512];
-		// int len = snprintf( helpText, 512, "CFA warning (UNIX pid:%ld) : program terminating with %u(0x%x) bytes of storage allocated but not freed.\n"
-		// 					"Possible cause is unfreed storage allocated by the program or system/library routines called from the program.\n",
-		// 					(long int)getpid(), total, total ); // always print the UNIX pid
-		// __cfaabi_dbg_bits_write( helpText, len );
-    } // if
-	#endif // __CFA_DEBUG__
-} // checkUnfreed
-
-#ifdef __CFA_DEBUG__
-extern "C" {
-void heapAppStart() {									// called by __cfaabi_appready_startup
-	appStart = allocfree;
-} // heapAppStart
-
-void heapAppStop() {									// called by __cfaabi_appready_startdown
-	checkUnfreed();
-} // heapAppStop
-} // extern "C"
-#endif // __CFA_DEBUG__
-
 
 struct HeapManager {
@@ -178,7 +177,7 @@
 					union {
 						struct {						// 32-bit word => 64-bit header, 64-bit word => 128-bit header
-							#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ && __U_WORDSIZE__ == 32
+							#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ && __SIZEOF_POINTER__ == 4
 							uint32_t padding;			// unused, force home/blocksize to overlay alignment in fake header
-							#endif // __U_WORDSIZE__ == 32 && __U_WORDSIZE__ == 32
+							#endif // __ORDER_BIG_ENDIAN__ && __U_WORDSIZE__ == 32
 
 							union {
@@ -191,7 +190,7 @@
 							};
 
-							#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ && __U_WORDSIZE__ == 32
+							#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ && __SIZEOF_POINTER__ == 4
 							uint32_t padding;			// unused, force home/blocksize to overlay alignment in fake header
-							#endif // __U_WORDSIZE__ == 32 && __U_WORDSIZE__ == 32
+							#endif // __ORDER_LITTLE_ENDIAN__ && __U_WORDSIZE__ == 32
 
 						};
@@ -204,5 +203,5 @@
 					#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
 					uint32_t alignment;					// low-order bits of home/blockSize used for tricks
-					#endif // __BYTE_ORDER__
+					#endif // __ORDER_LITTLE_ENDIAN__
 
 					uint32_t offset;
@@ -210,5 +209,5 @@
 					#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
 					uint32_t alignment;					// low-order bits of home/blockSize used for tricks
-					#endif // __BYTE_ORDER__
+					#endif // __ORDER_BIG_ENDIAN__
 				} fake;
 			} kind;
@@ -305,4 +304,5 @@
 	#endif // __CFA_DEBUG__
 
+	assert( heapManager.heapBegin == 0 );
 	heapManager{};
 } // memory_startup
@@ -672,5 +672,5 @@
 
 static inline void * malloc2( size_t size ) {			// necessary for malloc statistics
-    assert( heapManager.heapBegin != 0 ) ;				// heap started
+	assert( heapManager.heapBegin != 0 );
     void * area = doMalloc( size );
     if ( unlikely( area == 0 ) ) errno = ENOMEM;		// POSIX
Index: src/libcfa/stdlib
===================================================================
--- src/libcfa/stdlib	(revision a95c11749598f00148729214ecd78417a38fca57)
+++ src/libcfa/stdlib	(revision 0300979dcd79625c45973163a1e4c179b2303223)
@@ -10,6 +10,6 @@
 // Created On       : Thu Jan 28 17:12:35 2016
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Mon Jul 23 07:44:47 2018
-// Update Count     : 341
+// Last Modified On : Fri Jul 27 07:21:36 2018
+// Update Count     : 345
 //
 
@@ -19,5 +19,5 @@
 extern "C" {
 	void * memalign( size_t align, size_t size );		// malloc.h
-	void * memset( void * dest, int c, size_t size );	// string.h
+	void * memset( void * dest, int fill, size_t size ); // string.h
 	void * memcpy( void * dest, const void * src, size_t size ); // string.h
     void * cmemalign( size_t alignment, size_t noOfElems, size_t elemSize ); // CFA
@@ -127,6 +127,6 @@
 	// data, non-array types
 
-	T * memset( T * dest, char c ) {
-		return (T *)memset( dest, c, sizeof(T) );
+	T * memset( T * dest, char fill ) {
+		return (T *)memset( dest, fill, sizeof(T) );
 	} // memset
 
@@ -139,11 +139,11 @@
 	// data, array types
 
-	T * memset( T dest[], size_t dim, char c ) {
-		return (T *)(void *)memset( dest, c, dim * sizeof(T) );	// C memset
-	} // memset
-
-	T * memcpy( T dest[], const T src[], size_t dim ) {
+	T * amemset( T dest[], char fill, size_t dim ) {
+		return (T *)(void *)memset( dest, fill, dim * sizeof(T) ); // C memset
+	} // amemset
+
+	T * amemcpy( T dest[], const T src[], size_t dim ) {
 		return (T *)(void *)memcpy( dest, src, dim * sizeof(T) ); // C memcpy
-	} // memcpy
+	} // amemcpy
 } // distribution
 
@@ -203,6 +203,4 @@
 	E * bsearchu( E key, const E * vals, size_t dim );
 	size_t bsearchu( E key, const E * vals, size_t dim );
-
-	void qsort( E * vals, size_t dim );
 } // distribution
 
@@ -214,4 +212,8 @@
 	E * bsearchu( K key, const E * vals, size_t dim );
 	size_t bsearchu( K key, const E * vals, size_t dim );
+} // distribution
+
+forall( otype E | { int ?<?( E, E ); } ) {
+	void qsort( E * vals, size_t dim );
 } // distribution
 
Index: src/tests/.expect/alloc.txt
===================================================================
--- src/tests/.expect/alloc.txt	(revision a95c11749598f00148729214ecd78417a38fca57)
+++ src/tests/.expect/alloc.txt	(revision 0300979dcd79625c45973163a1e4c179b2303223)
@@ -49,5 +49,5 @@
 CFA array memset
 0xffffffff -nan, 0xffffffff -nan, 0xffffffff -nan, 0xffffffff -nan, 0xffffffff -nan, 0xffffffff -nan, 0xffffffff -nan, 0xffffffff -nan, 0xffffffff -nan, 0xffffffff -nan, 
-CFA memcpy
+CFA array memcpy
 0xffffffff -nan, 0xffffffff -nan, 0xffffffff -nan, 0xffffffff -nan, 0xffffffff -nan, 0xffffffff -nan, 0xffffffff -nan, 0xffffffff -nan, 0xffffffff -nan, 0xffffffff -nan, 
 
Index: src/tests/alloc.c
===================================================================
--- src/tests/alloc.c	(revision a95c11749598f00148729214ecd78417a38fca57)
+++ src/tests/alloc.c	(revision 0300979dcd79625c45973163a1e4c179b2303223)
@@ -10,6 +10,6 @@
 // Created On       : Wed Feb  3 07:56:22 2016
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Wed Jul 25 09:09:43 2018
-// Update Count     : 331
+// Last Modified On : Thu Jul 26 20:58:05 2018
+// Update Count     : 334
 //
 
@@ -219,11 +219,11 @@
 	printf( "\n" );
 
-	memset( sta, dim, fill );                           // CFA array memset, type safe
+	amemset( sta, fill, dim );							// CFA array memset, type safe
 	printf( "CFA array memset\n" );
 	for ( int i = 0; i < dim; i += 1 ) { printf( "%#x %a, ", sta[i].x, sta[i].y ); }
 	printf( "\n" );
 
-	memcpy( sta1, sta, dim );                           // CFA array memcpy, type safe
-	printf( "CFA memcpy\n" );
+	amemcpy( sta1, sta, dim );							// CFA array memcpy, type safe
+	printf( "CFA array memcpy\n" );
 	for ( int i = 0; i < dim; i += 1 ) { printf( "%#x %a, ", sta1[i].x, sta1[i].y ); }
 	printf( "\n" );
