Index: libcfa/src/common.hfa
===================================================================
--- libcfa/src/common.hfa	(revision d2b5d2d13fbbd91cca2e3529726480496ccb0577)
+++ libcfa/src/common.hfa	(revision 794db28fedf4d56b2d4db3057c6825fe0fab19e9)
@@ -10,6 +10,6 @@
 // Created On       : Wed Jul 11 17:54:36 2018
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Thu Jul 12 08:02:18 2018
-// Update Count     : 5
+// Last Modified On : Sat Aug 15 08:51:29 2020
+// Update Count     : 14
 // 
 
@@ -67,7 +67,13 @@
 
 static inline {
+	char min( char t1, char t2 ) { return t1 < t2 ? t1 : t2; } // optimization
+	intptr_t min( intptr_t t1, intptr_t t2 ) { return t1 < t2 ? t1 : t2; } // optimization
+	uintptr_t min( uintptr_t t1, uintptr_t t2 ) { return t1 < t2 ? t1 : t2; } // optimization
 	forall( otype T | { int ?<?( T, T ); } )
 	T min( T t1, T t2 ) { return t1 < t2 ? t1 : t2; }
 
+	char max( char t1, char t2 ) { return t1 > t2 ? t1 : t2; } // optimization
+	intptr_t max( intptr_t t1, intptr_t t2 ) { return t1 > t2 ? t1 : t2; } // optimization
+	uintptr_t max( uintptr_t t1, uintptr_t t2 ) { return t1 > t2 ? t1 : t2; } // optimization
 	forall( otype T | { int ?>?( T, T ); } )
 	T max( T t1, T t2 ) { return t1 > t2 ? t1 : t2; }
Index: libcfa/src/concurrency/coroutine.cfa
===================================================================
--- libcfa/src/concurrency/coroutine.cfa	(revision d2b5d2d13fbbd91cca2e3529726480496ccb0577)
+++ libcfa/src/concurrency/coroutine.cfa	(revision 794db28fedf4d56b2d4db3057c6825fe0fab19e9)
@@ -215,4 +215,8 @@
 		return cor;
 	}
+
+	struct $coroutine * __cfactx_cor_active(void) {
+		return active_coroutine();
+	}
 }
 
Index: libcfa/src/concurrency/invoke.c
===================================================================
--- libcfa/src/concurrency/invoke.c	(revision d2b5d2d13fbbd91cca2e3529726480496ccb0577)
+++ libcfa/src/concurrency/invoke.c	(revision 794db28fedf4d56b2d4db3057c6825fe0fab19e9)
@@ -29,4 +29,5 @@
 // Called from the kernel when starting a coroutine or task so must switch back to user mode.
 
+extern struct $coroutine * __cfactx_cor_active(void);
 extern struct $coroutine * __cfactx_cor_finish(void);
 extern void __cfactx_cor_leave ( struct $coroutine * );
@@ -35,4 +36,8 @@
 extern void disable_interrupts() OPTIONAL_THREAD;
 extern void enable_interrupts( __cfaabi_dbg_ctx_param );
+
+struct exception_context_t * this_exception_context() {
+	return &__get_stack( __cfactx_cor_active() )->exception_context;
+}
 
 void __cfactx_invoke_coroutine(
Index: libcfa/src/concurrency/invoke.h
===================================================================
--- libcfa/src/concurrency/invoke.h	(revision d2b5d2d13fbbd91cca2e3529726480496ccb0577)
+++ libcfa/src/concurrency/invoke.h	(revision 794db28fedf4d56b2d4db3057c6825fe0fab19e9)
@@ -98,4 +98,6 @@
 	}
 
+	struct exception_context_t * this_exception_context();
+
 	// struct which calls the monitor is accepting
 	struct __waitfor_mask_t {
Index: libcfa/src/exception.c
===================================================================
--- libcfa/src/exception.c	(revision d2b5d2d13fbbd91cca2e3529726480496ccb0577)
+++ libcfa/src/exception.c	(revision 794db28fedf4d56b2d4db3057c6825fe0fab19e9)
@@ -59,11 +59,9 @@
 
 
-// Temperary global exception context. Does not work with concurency.
-static struct exception_context_t shared_stack = {NULL, NULL};
-
 // Get the current exception context.
 // There can be a single global until multithreading occurs, then each stack
-// needs its own. It will have to be updated to handle that.
-struct exception_context_t * this_exception_context() {
+// needs its own. We get this from libcfathreads (no weak attribute).
+__attribute__((weak)) struct exception_context_t * this_exception_context() {
+	static struct exception_context_t shared_stack = {NULL, NULL};
 	return &shared_stack;
 }
Index: libcfa/src/heap.cfa
===================================================================
--- libcfa/src/heap.cfa	(revision d2b5d2d13fbbd91cca2e3529726480496ccb0577)
+++ libcfa/src/heap.cfa	(revision 794db28fedf4d56b2d4db3057c6825fe0fab19e9)
@@ -10,6 +10,6 @@
 // Created On       : Tue Dec 19 21:58:35 2017
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Sun Aug  9 12:23:20 2020
-// Update Count     : 894
+// Last Modified On : Wed Aug 12 16:43:38 2020
+// Update Count     : 902
 //
 
@@ -650,5 +650,8 @@
 		for ( HeapManager.Storage * p = freeLists[i].freeList; p != 0p; p = p->header.kind.real.next ) {
 		#else
-		for ( HeapManager.Storage * p = top( freeLists[i].freeList ); p != 0p; p = (p)`next->top ) {
+		// for ( HeapManager.Storage * p = top( freeLists[i].freeList ); p != 0p; p = (p)`next->top ) {
+		for ( HeapManager.Storage * p = top( freeLists[i].freeList ); p != 0p; /* p = getNext( p )->top */) {
+			typeof(p) temp = (( p )`next)->top;			// FIX ME: direct assignent fails, initialization works
+			p = temp;
 		#endif // BUCKETLOCK
 			total += size;
@@ -1162,5 +1165,5 @@
 		choose( option ) {
 		  case M_TOP_PAD:
-			heapExpand = ceiling( value, pageSize ); return 1;
+			heapExpand = ceiling2( value, pageSize ); return 1;
 		  case M_MMAP_THRESHOLD:
 			if ( setMmapStart( value ) ) return 1;
Index: libcfa/src/stdlib.hfa
===================================================================
--- libcfa/src/stdlib.hfa	(revision d2b5d2d13fbbd91cca2e3529726480496ccb0577)
+++ libcfa/src/stdlib.hfa	(revision 794db28fedf4d56b2d4db3057c6825fe0fab19e9)
@@ -10,6 +10,6 @@
 // Created On       : Thu Jan 28 17:12:35 2016
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Tue Aug 11 21:11:46 2020
-// Update Count     : 495
+// Last Modified On : Fri Aug 14 23:38:50 2020
+// Update Count     : 504
 //
 
@@ -39,4 +39,8 @@
 //---------------------------------------
 
+#include "common.hfa"
+
+//---------------------------------------
+
 // Macro because of returns
 #define $VAR_ALLOC( allocation, alignment ) \
@@ -152,6 +156,6 @@
 	} // alloc_set
 
-	T * alloc_set( size_t dim, const T fill[] ) {
-		return (T *)memcpy( (T *)alloc( dim ), fill, dim * sizeof(T) ); // initialize with fill value
+	T * alloc_set( size_t dimNew, const T fill[], size_t dimOld ) {
+		return (T *)memcpy( (T *)alloc( dimNew ), fill, min( dimNew, dimOld ) * sizeof(T) ); // initialize with fill value
 	} // alloc_set
 
@@ -220,6 +224,6 @@
 	} // alloc_align_set
 
-	T * alloc_align_set( size_t align, size_t dim, const T fill[] ) {
-		return (T *)memcpy( (T *)alloc_align( align, dim ), fill, dim * sizeof(T) );
+	T * alloc_align_set( size_t align, size_t dimNew, const T fill[], size_t dimOld ) {
+		return (T *)memcpy( (T *)alloc_align( align, dimNew ), fill, min( dimNew, dimOld ) * sizeof(T) );
 	} // alloc_align_set
 
@@ -374,8 +378,4 @@
 //---------------------------------------
 
-#include "common.hfa"
-
-//---------------------------------------
-
 extern bool threading_enabled(void) OPTIONAL_THREAD;
 
