Index: libcfa/src/exception.c
===================================================================
--- libcfa/src/exception.c	(revision fb0ae06606b0e7d507566017af9349c4ef930a18)
+++ libcfa/src/exception.c	(revision 980fb4e3ad96b48cc0912eafa1db767498aaa625)
@@ -10,6 +10,6 @@
 // Created On       : Mon Jun 26 15:13:00 2017
 // Last Modified By : Andrew Beach
-// Last Modified On : Thr May 21 12:18:00 2020
-// Update Count     : 20
+// Last Modified On : Wed Aug 12 13:55:00 2020
+// Update Count     : 21
 //
 
@@ -63,6 +63,5 @@
 
 	exception_t * current_exception;
-	int current_handler_index;
-} static shared_stack = {NULL, NULL, 0};
+} static shared_stack = {NULL, NULL};
 
 // Get the current exception context.
@@ -122,4 +121,15 @@
 
 // MEMORY MANAGEMENT =========================================================
+
+struct __cfaehm_node {
+	struct _Unwind_Exception unwind_exception;
+	struct __cfaehm_node * next;
+	int handler_index;
+};
+
+#define NODE_TO_EXCEPT(node) ((exception_t *)(1 + (node)))
+#define EXCEPT_TO_NODE(except) ((struct __cfaehm_node *)(except) - 1)
+#define UNWIND_TO_NODE(unwind) ((struct __cfaehm_node *)(unwind))
+#define NULL_MAP(map, ptr) ((ptr) ? (map(ptr)) : NULL)
 
 // How to clean up an exception in various situations.
@@ -137,15 +147,4 @@
 }
 
-// We need a piece of storage to raise the exception, for now its a single
-// piece.
-static struct _Unwind_Exception this_exception_storage;
-
-struct __cfaehm_node {
-	struct __cfaehm_node * next;
-};
-
-#define NODE_TO_EXCEPT(node) ((exception_t *)(1 + (node)))
-#define EXCEPT_TO_NODE(except) ((struct __cfaehm_node *)(except) - 1)
-
 // Creates a copy of the indicated exception and sets current_exception to it.
 static void __cfaehm_allocate_exception( exception_t * except ) {
@@ -161,14 +160,14 @@
 	}
 
+	// Initialize the node:
+	exception_t * except_store = NODE_TO_EXCEPT(store);
+	store->unwind_exception.exception_class = __cfaehm_exception_class;
+	store->unwind_exception.exception_cleanup = __cfaehm_exception_cleanup;
+	store->handler_index = 0;
+	except->virtual_table->copy( except_store, except );
+
 	// Add the node to the list:
-	store->next = EXCEPT_TO_NODE(context->current_exception);
-	context->current_exception = NODE_TO_EXCEPT(store);
-
-	// Copy the exception to storage.
-	except->virtual_table->copy( context->current_exception, except );
-
-	// Set up the exception storage.
-	this_exception_storage.exception_class = __cfaehm_exception_class;
-	this_exception_storage.exception_cleanup = __cfaehm_exception_cleanup;
+	store->next = NULL_MAP(EXCEPT_TO_NODE, context->current_exception);
+	context->current_exception = except_store;
 }
 
@@ -185,5 +184,5 @@
 	if ( context->current_exception == except ) {
 		node = to_free->next;
-		context->current_exception = (node) ? NODE_TO_EXCEPT(node) : 0;
+		context->current_exception = NULL_MAP(NODE_TO_EXCEPT, node);
 	} else {
 		node = EXCEPT_TO_NODE(context->current_exception);
@@ -213,5 +212,5 @@
 	// Verify actions follow the rules we expect.
 	verify((actions & _UA_CLEANUP_PHASE) && (actions & _UA_FORCE_UNWIND));
-	verify(!(actions & (_UA_SEARCH_PHASE | _UA_HANDER_FRAME)));
+	verify(!(actions & (_UA_SEARCH_PHASE | _UA_HANDLER_FRAME)));
 
 	if ( actions & _UA_END_OF_STACK ) {
@@ -222,9 +221,11 @@
 }
 
+static struct _Unwind_Exception cancel_exception_storage;
+
 // Cancel the current stack, prefroming approprate clean-up and messaging.
 void __cfaehm_cancel_stack( exception_t * exception ) {
 	// TODO: Detect current stack and pick a particular stop-function.
 	_Unwind_Reason_Code ret;
-	ret = _Unwind_ForcedUnwind( &this_exception_storage, _Stop_Fn, (void*)0x22 );
+	ret = _Unwind_ForcedUnwind( &cancel_exception_storage, _Stop_Fn, (void*)0x22 );
 	printf("UNWIND ERROR %d after force unwind\n", ret);
 	abort();
@@ -247,9 +248,10 @@
 static void __cfaehm_begin_unwind(void(*defaultHandler)(exception_t *)) {
 	struct exception_context_t * context = this_exception_context();
-	struct _Unwind_Exception * storage = &this_exception_storage;
 	if ( NULL == context->current_exception ) {
 		printf("UNWIND ERROR missing exception in begin unwind\n");
 		abort();
 	}
+	struct _Unwind_Exception * storage =
+		&EXCEPT_TO_NODE(context->current_exception)->unwind_exception;
 
 	// Call stdlibc to raise the exception
@@ -419,5 +421,5 @@
 				_Unwind_Reason_Code ret = (0 == index)
 					? _URC_CONTINUE_UNWIND : _URC_HANDLER_FOUND;
-				context->current_handler_index = index;
+				UNWIND_TO_NODE(unwind_exception)->handler_index = index;
 
 				// Based on the return value, check if we matched the exception
@@ -425,4 +427,5 @@
 					__cfadbg_print_safe(exception, " handler found\n");
 				} else {
+					// TODO: Continue the search if there is more in the table.
 					__cfadbg_print_safe(exception, " no handler\n");
 				}
@@ -516,5 +519,5 @@
 	// Exception handler
 	// Note: Saving the exception context on the stack breaks termination exceptions.
-	catch_block( this_exception_context()->current_handler_index,
+	catch_block( EXCEPT_TO_NODE( this_exception_context()->current_exception )->handler_index,
 	             this_exception_context()->current_exception );
 }
Index: tests/exceptions/.expect/trash.txt
===================================================================
--- tests/exceptions/.expect/trash.txt	(revision 980fb4e3ad96b48cc0912eafa1db767498aaa625)
+++ tests/exceptions/.expect/trash.txt	(revision 980fb4e3ad96b48cc0912eafa1db767498aaa625)
@@ -0,0 +1,2 @@
+inner yang
+outer yin
Index: tests/exceptions/trash.cfa
===================================================================
--- tests/exceptions/trash.cfa	(revision 980fb4e3ad96b48cc0912eafa1db767498aaa625)
+++ tests/exceptions/trash.cfa	(revision 980fb4e3ad96b48cc0912eafa1db767498aaa625)
@@ -0,0 +1,27 @@
+// Make sure throw-catch during unwind does not trash internal data.
+
+#include <exception.hfa>
+#include <stdio.h>
+
+TRIVIAL_EXCEPTION(yin);
+TRIVIAL_EXCEPTION(yang);
+
+int main(int argc, char * argv[]) {
+	try {
+		try {
+			throw (yin){};
+		} finally {
+			try {
+				throw (yang){};
+			} catch (yin *) {
+				printf("inner yin\n");
+			} catch (yang *) {
+				printf("inner yang\n");
+			}
+		}
+	} catch (yin *) {
+		printf("outer yin\n");
+	} catch (yang *) {
+		printf("outer yang\n");
+	}
+}
