Index: src/examples/gc_no_raii/bug-repro/field.c
===================================================================
--- src/examples/gc_no_raii/bug-repro/field.c	(revision 16cfd8c1c8906f3433126a396d7e0b638574cd2a)
+++ src/examples/gc_no_raii/bug-repro/field.c	(revision 16cfd8c1c8906f3433126a396d7e0b638574cd2a)
@@ -0,0 +1,130 @@
+extern "C" {
+#include <stdbool.h>
+#include <stdint.h>
+}
+
+#include <stdlib>
+
+//------------------------------------------------------------------------------
+//Declaration
+trait allocator_c(otype T, otype allocator_t)
+{
+	void ctor(allocator_t* const);
+	void dtor(allocator_t* const);
+	void realloc(allocator_t* const, size_t);
+	T* data(allocator_t* const);
+};
+
+forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
+struct vector
+{
+	allocator_t storage;
+	size_t size;
+};
+
+int global = 3;
+
+struct card_table_t
+{
+	size_t count;
+	void* cards_start[100];
+};
+
+static inline void ctor(card_table_t* const this)
+{
+	this->count = 0;
+}
+
+struct gc_memory_pool
+{
+	struct memory_pool* mirror;
+	struct memory_pool* next;
+
+	uint8_t type_code;
+
+	card_table_t* cards;
+
+	uint8_t* end_p;
+	uint8_t* free_p;
+	uint8_t start_p[1];
+};
+
+void ctor(	gc_memory_pool *const this,
+		size_t size,
+		gc_memory_pool* next,
+		gc_memory_pool* mirror,
+		uint8_t type
+	);
+
+void dtor(gc_memory_pool *const this);
+
+struct gc_pool_object_iterator
+{
+	struct gc_object_header* object;
+	#if _DEBUG
+		intptr_t lower_limit;
+		intptr_t upper_limit;
+	#endif
+};
+
+void ctor(
+		gc_pool_object_iterator* const this,
+		void* start_object
+		#if _DEBUG
+			, intptr_t pool_start
+			, intptr_t pool_end
+		#endif
+	);
+
+bool ?!=?(const gc_pool_object_iterator lhs, const gc_pool_object_iterator rhs);
+
+gc_pool_object_iterator begin(gc_memory_pool* const this);
+gc_pool_object_iterator end(gc_memory_pool* const);
+
+gc_pool_object_iterator* ++?(gc_pool_object_iterator* it);
+
+const void* *?(const gc_pool_object_iterator it);
+void* *?(gc_pool_object_iterator it);
+
+static inline bool gc_pool_is_from_space(const gc_memory_pool* pool)
+{
+	return false;
+}
+
+void gc_reset_pool(gc_memory_pool* const pool);
+
+static inline size_t gc_pool_size_used(const gc_memory_pool* pool)
+{
+	return pool->free_p - pool->start_p;
+}
+
+static inline size_t gc_pool_size_total(const gc_memory_pool* pool)
+{
+	return pool->end_p - pool->start_p;
+}
+
+static inline size_t gc_pool_size_left(const gc_memory_pool* pool)
+{
+	return pool->end_p - pool->free_p;
+}
+
+void* gc_pool_allocate(gc_memory_pool* const pool, size_t size, bool zero);
+
+gc_pool_object_iterator gc_pool_iterator_for(gc_memory_pool* const pool, void* member);
+
+void ctor(gc_memory_pool *const this, size_t size, gc_memory_pool* next, gc_memory_pool* mirror, uint8_t type)
+{
+	this->mirror = mirror;
+	this->next = next;
+	this->type_code = type;
+
+	this->cards = malloc();
+	ctor(this->cards);
+
+	this->end_p = ((uint8_t*)this) + size;
+	this->free_p = this->start_p;
+
+	// check(gc_pool_of(this) == this);
+	// check(this->cards);
+	// gc_reset_pool(this);
+}
Index: src/examples/gc_no_raii/bug-repro/while.c
===================================================================
--- src/examples/gc_no_raii/bug-repro/while.c	(revision 16cfd8c1c8906f3433126a396d7e0b638574cd2a)
+++ src/examples/gc_no_raii/bug-repro/while.c	(revision 16cfd8c1c8906f3433126a396d7e0b638574cd2a)
@@ -0,0 +1,14 @@
+extern void* get_member();
+extern void* get_next();
+
+void main()
+{
+	void* member = get_member();
+	void* start_obj = get_next();
+
+	do
+	{
+		start_obj = (void*) ( ((unsigned long int)start_obj) + sizeof(void*) );
+	}
+	while(start_obj > member || !(start_obj) );
+}
Index: src/examples/gc_no_raii/src/allocate-pool.c
===================================================================
--- src/examples/gc_no_raii/src/allocate-pool.c	(revision 8c8b614c9556d4f3da698b270c0c4aaf015acedf)
+++ src/examples/gc_no_raii/src/allocate-pool.c	(revision 16cfd8c1c8906f3433126a396d7e0b638574cd2a)
@@ -2,4 +2,9 @@
 #define _DARWIN_C_SOURCE /* for MAP_ANON on OS X */
 
+#ifdef __cforall
+extern "C"{
+#else
+#error missing cfa define
+#endif
 
 /* for standards info */
@@ -24,8 +29,4 @@
 #if _POSIX_VERSION
 #include <sys/mman.h>
-#endif
-
-#ifdef CFA
-extern "C"{
 #endif
 
@@ -59,5 +60,5 @@
 }
 
-#ifdef CFA
+#ifdef __cforall
 }
 #endif
Index: src/examples/gc_no_raii/src/allocate-pool.h
===================================================================
--- src/examples/gc_no_raii/src/allocate-pool.h	(revision 8c8b614c9556d4f3da698b270c0c4aaf015acedf)
+++ src/examples/gc_no_raii/src/allocate-pool.h	(revision 16cfd8c1c8906f3433126a396d7e0b638574cd2a)
@@ -2,5 +2,5 @@
 #define _GGGGC_ALlOCATE_POOL_H_
 
-#ifdef __cplusplus
+#ifdef __cforall
 extern "C" {
 #endif
@@ -8,5 +8,5 @@
 void* pal_allocPool(size_t size, int mustSucceed);
 
-#ifdef __cplusplus
+#ifdef __cforall
 }
 #endif
Index: src/examples/gc_no_raii/src/internal/card_table.h
===================================================================
--- src/examples/gc_no_raii/src/internal/card_table.h	(revision 16cfd8c1c8906f3433126a396d7e0b638574cd2a)
+++ src/examples/gc_no_raii/src/internal/card_table.h	(revision 16cfd8c1c8906f3433126a396d7e0b638574cd2a)
@@ -0,0 +1,63 @@
+#pragma once
+
+#include <stdlib>
+
+#include "globals.h"
+#include "tools.h"
+
+static inline size_t card_of(void* address)
+{
+	size_t card = ( ((intptr_t)address) & CARDS_OFFSET_MASK ) >> CARDS_SIZE_EXP;
+	check(card < CARDS_COUNT);
+	return card;
+}
+
+struct card_table_t
+{
+	size_t count;
+	void* cards_start[CARDS_COUNT];
+};
+
+static inline void ctor(card_table_t* const this)
+{
+	this->count = 0;
+}
+
+static inline void dtor(card_table_t* const this)
+{
+
+}
+
+static inline void* object_at(card_table_t* const this, size_t card_number)
+{
+	return card_number < this->count ? this->cards_start[card_number] : NULL;
+}
+
+static inline void register_object(card_table_t* const this, void* object)
+{
+	size_t card = card_of(object);
+	if(card < this->count)
+	{
+		intptr_t card_obj_add = (intptr_t)object_at(this, card);
+		intptr_t obj_add = (intptr_t)object;
+		if(card_obj_add > obj_add)
+		{
+			this->cards_start[card] = object;
+		}
+	}
+	else
+	{
+		check(card == count);
+		this->count++;
+		this->cards_start[card] = object;
+	}
+}
+
+static inline void reset(card_table_t* const this)
+{
+	for(size_t i = 0; i < this->count; i++)
+	{
+		this->cards_start[i] = NULL;
+	}
+	this->count = 0;
+}
Index: src/examples/gc_no_raii/src/internal/collector.c
===================================================================
--- src/examples/gc_no_raii/src/internal/collector.c	(revision 8c8b614c9556d4f3da698b270c0c4aaf015acedf)
+++ src/examples/gc_no_raii/src/internal/collector.c	(revision 16cfd8c1c8906f3433126a396d7e0b638574cd2a)
@@ -1,10 +1,11 @@
 #include "collector.h"
 
-#include <stdbool.h>
-#include <stdint.h>
-#include <stdlib.h>
+#ifdef __cforall
+extern "C" {
+#endif
 #include <string.h>
-
-#include <fstream>
+#ifdef __cforall
+}
+#endif
 
 #include "state.h"
@@ -138,5 +139,5 @@
 
 		intptr_t* ref = &field->ptr;
-		// push_back(worklist, ref);
+		push_back(worklist, ref);
 
 		field = field->next;
Index: src/examples/gc_no_raii/src/internal/collector.h
===================================================================
--- src/examples/gc_no_raii/src/internal/collector.h	(revision 8c8b614c9556d4f3da698b270c0c4aaf015acedf)
+++ src/examples/gc_no_raii/src/internal/collector.h	(revision 16cfd8c1c8906f3433126a396d7e0b638574cd2a)
@@ -1,6 +1,5 @@
 #pragma once
 
-#include <stddef.h>
-#include <stdint.h>
+#include <stdlib>
 
 #include "tools.h"
@@ -14,10 +13,10 @@
 #include "tools/worklist.h"
 
-inline bool gc_is_managed(void* address)
+static inline bool gc_is_managed(void* address)
 {
 	return gc_is_in_heap(gc_get_state(), address);
 }
 
-inline gc_object_header* gc_get_object_ptr(void* ptr)
+static inline gc_object_header* gc_get_object_ptr(void* ptr)
 {
 	void* clean = gc_get_aligned_ptr(ptr);
@@ -25,10 +24,10 @@
 }
 
-inline struct gc_memory_pool* gc_pool_of(void* address)
+static inline struct gc_memory_pool* gc_pool_of(void* address)
 {
 	return (struct gc_memory_pool*)(((intptr_t)address) & POOL_PTR_MASK);
 }
 
-inline void gc_conditional_collect()
+static inline void gc_conditional_collect()
 {
 	if(gc_needs_collect(gc_get_state()))
Index: src/examples/gc_no_raii/src/internal/gc_tools.h
===================================================================
--- src/examples/gc_no_raii/src/internal/gc_tools.h	(revision 8c8b614c9556d4f3da698b270c0c4aaf015acedf)
+++ src/examples/gc_no_raii/src/internal/gc_tools.h	(revision 16cfd8c1c8906f3433126a396d7e0b638574cd2a)
@@ -7,15 +7,15 @@
 #include "globals.h"
 
-inline bool gc_is_aligned(void* address)
+static inline bool gc_is_aligned(void* address)
 {
 	return (((intptr_t)address) & (~OBJECT_PTR_MASK)) == 0;
 }
 
-inline void* gc_get_aligned_ptr(void* address)
+static inline void* gc_get_aligned_ptr(void* address)
 {
 	return (void*)(((intptr_t)address) & (OBJECT_PTR_MASK));
 }
 
-inline void* gc_write_aligned_ptr(void** reference, void* address)
+static inline void* gc_write_aligned_ptr(void** reference, void* address)
 {
 	size_t ref_last_bits = ((intptr_t)*reference) & (~OBJECT_PTR_MASK);
@@ -28,5 +28,5 @@
 }
 
-inline size_t gc_compute_size(size_t size)
+static inline size_t gc_compute_size(size_t size)
 {
 	size_t word_size = ((size - 1) / OBJECT_ALLIGNMENT) + 1;
Index: src/examples/gc_no_raii/src/internal/memory_pool.c
===================================================================
--- src/examples/gc_no_raii/src/internal/memory_pool.c	(revision 16cfd8c1c8906f3433126a396d7e0b638574cd2a)
+++ src/examples/gc_no_raii/src/internal/memory_pool.c	(revision 16cfd8c1c8906f3433126a396d7e0b638574cd2a)
@@ -0,0 +1,159 @@
+#include "memory_pool.h"
+
+#include <stdlib>
+
+// const size_t gc_pool_header_size = (size_t)(  &(((gc_memory_pool*)NULL)->start_p) );
+
+void ctor(gc_memory_pool *const this, size_t size, gc_memory_pool* next, gc_memory_pool* mirror, uint8_t type)
+{
+	this->mirror = mirror;
+	this->next = next;
+	this->type_code = type;
+
+	card_table_t* new = malloc();
+	this->cards = new;
+	ctor(this->cards);
+
+	this->end_p = ((uint8_t*)this) + size;
+	this->free_p = this->start_p;
+
+	// check(gc_pool_of(this) == this);
+	// check(this->cards);
+	// gc_reset_pool(this);
+}
+
+// void dtor(gc_memory_pool *const this)
+// {
+// 	dtor(this->cards);
+// 	free(this->cards);
+// }
+//
+// void gc_reset_pool(gc_memory_pool *const this)
+// {
+// 	this->free_p = this->start_p;
+// 	#if _DEBUG
+// 		memset(this->start_p, 0xCD, gc_pool_total_size(this));
+// 	#endif
+//
+// 	check(this->cards);
+// 	reset(this->cards);
+//
+// 	check(gc_pool_size_left(this) == gc_pool_total_size(this));
+// }
+//
+// void* gc_pool_allocate(gc_memory_pool *const this, size_t size, bool zero)
+// {
+// 	void* ret = this->free_p;
+//
+// 	this->free_p += size;
+//
+// 	if (zero) memset(ret, 0x00, size);
+//
+// 	check(this->cards);
+// 	register_object(this->cards, ret);
+//
+// 	return ret;
+// }
+//
+// gc_pool_object_iterator gc_pool_iterator_for(gc_memory_pool* const this, void* member)
+// {
+// 	size_t card = card_of(member);
+// 	intptr_t member_add = (intptr_t)member;
+// 	void* start_obj;
+// 	intptr_t start_obj_add;
+//
+// 	do
+// 	{
+// 		check(card < CARDS_COUNT);
+// 		start_obj = object_at(this->cards, card);
+// 		check(card != 0 || start_obj);
+// 		card--;
+// 		start_obj_add = (intptr_t)start_obj;
+// 	}
+// 	while(start_obj_add > member_add || start_obj_add != 0);
+//
+// 	check(start_obj);
+//
+// 	gc_pool_object_iterator it;
+// 	ctor( &it,
+// 		(gc_object_header*)start_obj
+// 		#if _DEBUG
+// 			, (intptr_t)this->start_p
+// 			, (intptr_t)this->free_p
+// 		#endif
+// 	);
+// 	return it;
+// }
+//
+// void ctor(
+// 		gc_pool_object_iterator* const this,
+// 		struct gc_object_header* start_object
+// 		#if _DEBUG
+// 			, intptr_t pool_start
+// 			, intptr_t pool_end
+// 		#endif
+// 	)
+// {
+// 	this->object = start_object;
+// 	#if _DEBUG
+// 		this->lower_limit = pool_start;
+// 		this->upper_limit = pool_end;
+// 	#endif
+//
+// 	check( ((intptr_t)start_object) >= lower_limit );
+// 	check( ((intptr_t)start_object) <= upper_limit );
+// }
+//
+// bool ?!=?(const gc_pool_object_iterator lhs, const gc_pool_object_iterator rhs)
+// {
+// 	return lhs.object != rhs.object;
+// }
+//
+// gc_pool_object_iterator begin(gc_memory_pool* const this)
+// {
+// 	gc_pool_object_iterator it;
+// 	ctor( &it,
+// 		(gc_object_header*)this->start_p,
+// 		#if _DEBUG
+// 			, (intptr_t)this->start_p
+// 			, (intptr_t)this->free_p
+// 		#endif
+// 	);
+// 	return it;
+// }
+//
+// gc_pool_object_iterator end(gc_memory_pool* const this)
+// {
+// 	gc_pool_object_iterator it;
+// 	ctor( &it,
+// 		(gc_object_header*)this->free_p,
+// 		#if _DEBUG
+// 			, (intptr_t)this->start_p
+// 			, (intptr_t)this->free_p
+// 		#endif
+// 	);
+// 	return it;
+// }
+//
+// gc_pool_object_iterator* ++?(gc_pool_object_iterator* it)
+// {
+// 	intptr_t next_ptr = ((intptr_t)it->object) + it->object->size;
+// 	check(next_ptr > lower_limit);
+// 	check(next_ptr <= upper_limit);
+//
+// 	gc_object_header* next_obj = ((gc_object_header*)next_ptr);
+// 	check(next_ptr == upper_limit || is_valide(next_obj));
+//
+// 	it->object = next_obj;
+// 	return it;
+// }
+//
+// const struct gc_object_header* *?(const gc_pool_object_iterator it)
+// {
+// 	return it.object;
+// }
+//
+// struct gc_object_header* *?(gc_pool_object_iterator it)
+// {
+// 	return it.object;
+// }
Index: src/examples/gc_no_raii/src/internal/memory_pool.h
===================================================================
--- src/examples/gc_no_raii/src/internal/memory_pool.h	(revision 8c8b614c9556d4f3da698b270c0c4aaf015acedf)
+++ src/examples/gc_no_raii/src/internal/memory_pool.h	(revision 16cfd8c1c8906f3433126a396d7e0b638574cd2a)
@@ -1,13 +1,14 @@
 #pragma once
 
+extern "C" {
+#include <stdbool.h>
 #include <stdint.h>
+}
 
 #include "tools.h"
 
-// #include "card_table.h"
-#include "collector.h"
+#include "card_table.h"
 #include "globals.h"
-
-typedef int cardtable_ptr_t;
+#include "state.h"
 
 struct gc_memory_pool
@@ -18,5 +19,5 @@
 	uint8_t type_code;
 
-	cardtable_ptr_t cards;
+	card_table_t* cards;
 
 	uint8_t* end_p;
@@ -25,14 +26,15 @@
 };
 
-void gc_memory_pool_ctor(gc_memory_pool *const this,
-	size_t size,
-	gc_memory_pool* next,
-	gc_memory_pool* mirror,
-     uint8_t type
+void ctor(	gc_memory_pool *const this,
+		size_t size,
+		gc_memory_pool* next,
+		gc_memory_pool* mirror,
+		uint8_t type
 	);
+
+void dtor(gc_memory_pool *const this);
 
 struct gc_pool_object_iterator
 {
-
 	struct gc_object_header* object;
 	#if _DEBUG
@@ -43,5 +45,6 @@
 
 
-void gc_pool_object_iterator_ctor(
+void ctor(
+		gc_pool_object_iterator* const this,
 		struct gc_object_header* start_object
 		#if _DEBUG
@@ -53,5 +56,5 @@
 bool ?!=?(const gc_pool_object_iterator lhs, const gc_pool_object_iterator rhs);
 
-gc_pool_object_iterator begin(gc_memory_pool* const);
+gc_pool_object_iterator begin(gc_memory_pool* const this);
 gc_pool_object_iterator end(gc_memory_pool* const);
 
@@ -61,29 +64,27 @@
 struct gc_object_header* *?(gc_pool_object_iterator it);
 
-inline bool gc_pool_is_from_space(const gc_memory_pool* pool)
+static inline bool gc_pool_is_from_space(const gc_memory_pool* pool)
 {
 	return gc_from_space_code(gc_get_state()) == pool->type_code;
 }
 
-void gc_reset_pool(gc_memory_pool* pool);
+void gc_reset_pool(gc_memory_pool* const pool);
 
-inline size_t gc_pool_size_used(const gc_memory_pool* pool)
+static inline size_t gc_pool_size_used(const gc_memory_pool* pool)
 {
 	return pool->free_p - pool->start_p;
 }
 
-inline size_t gc_pool_size_total(const gc_memory_pool* pool)
+static inline size_t gc_pool_size_total(const gc_memory_pool* pool)
 {
 	return pool->end_p - pool->start_p;
 }
 
-inline size_t gc_pool_size_left(const gc_memory_pool* pool)
+static inline size_t gc_pool_size_left(const gc_memory_pool* pool)
 {
 	return pool->end_p - pool->free_p;
 }
 
-void* gc_pool_allocate(gc_memory_pool* pool, size_t size, bool zero);
+void* gc_pool_allocate(gc_memory_pool* const pool, size_t size, bool zero);
 
-gc_pool_object_iterator gc_pool_iterator_for(gc_memory_pool* pool, void* member);
-
-gc_pool_object_iterator gc_pool_end(gc_memory_pool* pool);
+gc_pool_object_iterator gc_pool_iterator_for(gc_memory_pool* const pool, void* member);
Index: src/examples/gc_no_raii/src/internal/object_header.c
===================================================================
--- src/examples/gc_no_raii/src/internal/object_header.c	(revision 8c8b614c9556d4f3da698b270c0c4aaf015acedf)
+++ src/examples/gc_no_raii/src/internal/object_header.c	(revision 16cfd8c1c8906f3433126a396d7e0b638574cd2a)
@@ -6,10 +6,27 @@
 #include "gcpointers.h"
 
-placement_copy_ctor(void* address, const gc_object_header* const other)
+void ctor(gc_object_header* const this, size_t inSize)
 {
-	gc_object_header* const this = (gc_object_header*)address;
 	#if _DEBUG
 		this->canary_start = CANARY_VALUE;
 	#endif
+
+	this->size = inSize;
+	this->root_chain = NULL;
+	this->type_chain = NULL;
+	this->forward = NULL;
+	this->is_forwarded = false;
+
+	#if _DEBUG
+		this->canary_end = CANARY_VALUE;
+	#endif
+}
+
+void copy_ctor(gc_object_header* const this, const gc_object_header* const other)
+{
+	#if _DEBUG
+		this->canary_start = CANARY_VALUE;
+	#endif
+
 	this->size = other->size;
 	this->root_chain = other->root_chain;
@@ -17,47 +34,44 @@
 	this->forward = NULL;
 	this->is_forwarded = false;
+
 	#if _DEBUG
 		this->canary_end = CANARY_VALUE;
 	#endif
+
+	gcpointer_t* root = this->root_chain;
+	while(root)
 	{
-		gcpointer_t* root = this->root_chain;
-		while(root)
-		{
-			check(get_object_ptr(root->ptr) == other);
-			intptr_t int_this = (intptr_t)this;
-			intptr_t int_next = int_this + sizeof(gc_object_header);
-			intptr_t* root_ptr = root->ptr;
-			*root_ptr = int_next;
+		check(get_object_ptr(root->ptr) == other);
+		root->ptr = ((intptr_t)this) + sizeof(gc_object_header);
 
-			check(get_object_ptr(root->ptr) == this);
-			root = root->next;
-		}
+		check(get_object_ptr(root->ptr) == this);
+		root = root->next;
+	}
 
-		gcpointer_t* type = other->type_chain;
+	gcpointer_t* type = other->type_chain;
 
-		while(type)
-		{
-			check((intptr_t)type < (intptr_t)((intptr_t)other + other->size));
+	while(type)
+	{
+		check((intptr_t)type < (intptr_t)((intptr_t)other + other->size));
 
-			size_t offset = (intptr_t)type - (intptr_t)other;
-			check(offset < size);
+		size_t offset = (intptr_t)type - (intptr_t)other;
+		check(offset < size);
 
-			gcpointer_t* member_ptr = (gcpointer_t*)( (intptr_t)this + offset );
+		gcpointer_t* member_ptr = (gcpointer_t*)( (intptr_t)this + offset );
 
-			if(!this->type_chain) this->type_chain = member_ptr;
+		if(!this->type_chain) this->type_chain = member_ptr;
 
-			size_t next_offset = type->next ? (intptr_t)type->next - (intptr_t)other : 0;
-			check(next_offset < size);
+		size_t next_offset = type->next ? (intptr_t)type->next - (intptr_t)other : 0;
+		check(next_offset < size);
 
-			gcpointer_t* next_ptr = type->next ? (gcpointer_t*)((intptr_t)this + next_offset) : NULL;
+		gcpointer_t* next_ptr = type->next ? (gcpointer_t*)((intptr_t)this + next_offset) : NULL;
 
-			member_ptr->ptr = type->ptr;
-			member_ptr->next = next_ptr;
+		member_ptr->ptr = type->ptr;
+		member_ptr->next = next_ptr;
 
-			type = type->next;
-		}
+		type = type->next;
+	}
 
-		check(is_valide(this));
-	}
+	check(is_valide(this));
 }
 
Index: src/examples/gc_no_raii/src/internal/object_header.h
===================================================================
--- src/examples/gc_no_raii/src/internal/object_header.h	(revision 8c8b614c9556d4f3da698b270c0c4aaf015acedf)
+++ src/examples/gc_no_raii/src/internal/object_header.h	(revision 16cfd8c1c8906f3433126a396d7e0b638574cd2a)
@@ -30,4 +30,18 @@
 };
 
-gc_object_header* placement_ctor(void* address, size_t size);
-gc_object_header* placement_copy_ctor(void* address, const gc_object_header* const other);
+void ctor(gc_object_header* const this, size_t size);
+void copy_ctor(gc_object_header* const this, const gc_object_header* const other);
+
+static inline gc_object_header* placement_ctor(void* address, size_t size)
+{
+	gc_object_header* const this = (gc_object_header* const) address;
+	ctor(this, size);
+	return this;
+}
+
+static inline gc_object_header* placement_copy_ctor(void* address, const gc_object_header* const other)
+{
+	gc_object_header* const this = (gc_object_header* const) address;
+	copy_ctor(this, other);
+	return this;
+}
Index: src/examples/gc_no_raii/src/internal/state.c
===================================================================
--- src/examples/gc_no_raii/src/internal/state.c	(revision 8c8b614c9556d4f3da698b270c0c4aaf015acedf)
+++ src/examples/gc_no_raii/src/internal/state.c	(revision 16cfd8c1c8906f3433126a396d7e0b638574cd2a)
@@ -12,5 +12,4 @@
 #include "globals.h"
 #include "memory_pool.h"
-// #include "memory_pool_iterator.h"
 #include "object_header.h"
 
@@ -46,5 +45,11 @@
 }
 
-bool gc_state_is_in_heap(const gc_state* const this, void* address)
+void dtor(gc_state *const this)
+{
+	dtor(&this->pools_table);
+	this->is_initialized = false;
+}
+
+bool gc_is_in_heap(const gc_state* const this, const void* const address)
 {
 	gc_memory_pool* target_pool = gc_pool_of(address);
@@ -56,5 +61,5 @@
 }
 
-bool gc_state_is_in_to_space(const gc_state* const this, void* address)
+bool gc_is_in_to_space(const gc_state* const this, const void* const address)
 {
 	gc_memory_pool* target_pool = gc_pool_of(address);
@@ -73,5 +78,5 @@
 	gc_memory_pool* pool = gc_pool_of(member);
 	gc_pool_object_iterator it = gc_pool_iterator_for(pool, member);
-	gc_pool_object_iterator end = gc_pool_end(pool);
+	gc_pool_object_iterator end = end(pool);
 
 	while(it != end)
@@ -94,5 +99,5 @@
 }
 
-void* gc_try_allocate(gc_state *const this, size_t size)
+void* gc_try_allocate(gc_state* const this, size_t size)
 {
 	gc_memory_pool* pool = this->from_space;
@@ -109,5 +114,5 @@
 }
 
-void gc_state_allocate_pool(gc_state *const this)
+void gc_allocate_pool(gc_state *const this)
 {
 	gc_memory_pool* old_from_space = this->from_space;
@@ -117,6 +122,6 @@
       this->to_space = (gc_memory_pool*)(pal_allocPool(POOL_SIZE_BYTES, 1));
 
-      gc_memory_pool_ctor(this->from_space, POOL_SIZE_BYTES, old_from_space, this->to_space,   this->from_code);
-      gc_memory_pool_ctor(this->to_space,   POOL_SIZE_BYTES, old_to_space,   this->from_space, (~this->from_code) & 0x01);
+      ctor(this->from_space, POOL_SIZE_BYTES, old_from_space, this->to_space,   this->from_code);
+      ctor(this->to_space,   POOL_SIZE_BYTES, old_to_space,   this->from_space, (~this->from_code) & 0x01);
 
 	this->total_space += gc_pool_size_used(this->from_space);
@@ -126,5 +131,5 @@
 }
 
-void gc_state_collect(gc_state* const this)
+void gc_collect(gc_state* const this)
 {
 	// DEBUG("collecting");
@@ -149,5 +154,5 @@
 	gc_state_calc_usage(this);
 
-	if(gc_needs_collect(this)) gc_state_allocate_pool(this);
+	if(gc_needs_collect(this)) gc_allocate_pool(this);
 
 	// DEBUG("done");
@@ -281,5 +286,5 @@
 			while(potential_ref < (void**)pool->m_free)
 			{
-				check(!gc_is_in_heap(*potential_ref));
+				check(!gc_is_in_heap(this, *potential_ref));
 				potential_ref++;
 			}
Index: src/examples/gc_no_raii/src/internal/state.h
===================================================================
--- src/examples/gc_no_raii/src/internal/state.h	(revision 8c8b614c9556d4f3da698b270c0c4aaf015acedf)
+++ src/examples/gc_no_raii/src/internal/state.h	(revision 16cfd8c1c8906f3433126a396d7e0b638574cd2a)
@@ -7,5 +7,5 @@
 #include "vector.h"
 
-typedef vector(struct gc_memory_pool*, heap_allocator(struct gc_memory_pool*)) pools_table_t;
+// typedef vector(struct gc_memory_pool*, heap_allocator(struct gc_memory_pool*)) pools_table_t;
 
 struct gc_state
@@ -19,28 +19,30 @@
 	size_t used_space;
 
-	pools_table_t 	pools_table;
+	// pools_table_t 	pools_table;
 	size_t 		pools_table_count;
 };
 
-void ctor(struct gc_state* state);
+void ctor(gc_state* const state);
+
+void dtor(gc_state* const state);
 
 gc_state* gc_get_state();
 
-inline bool gc_needs_collect(gc_state* state)
+static inline bool gc_needs_collect(gc_state* state)
 {
 	return state->used_space * 2 > state->total_space;
 }
 
-void gc_collect(gc_state* state);
+void gc_collect(gc_state* const this);
 
-void* gc_try_allocate(gc_state* state, size_t size);
+void* gc_try_allocate(gc_state* const this, size_t size);
 
-void gc_allocate_pool(gc_state* state);
+void gc_allocate_pool(gc_state* const state);
 
-bool gc_is_in_heap(const gc_state* state, void* address);
+bool gc_is_in_heap(const gc_state* const state, const void* const address);
 
-bool gc_is_in_to_space(const gc_state* state, void* address);
+bool gc_is_in_to_space(const gc_state* const state, const void* const address);
 
-inline uint8_t gc_from_space_code(const gc_state *const this)
+static inline uint8_t gc_from_space_code(const gc_state *const this)
 {
 	return this->from_code;
@@ -49,5 +51,5 @@
 struct gc_object_header* gc_get_object_for_ref(gc_state* state, void*);
 
-inline void gc_register_allocation(gc_state* state, size_t size)
+static inline void gc_register_allocation(gc_state* state, size_t size)
 {
 	state->used_space += size;
Index: src/examples/gc_no_raii/src/tools.h
===================================================================
--- src/examples/gc_no_raii/src/tools.h	(revision 8c8b614c9556d4f3da698b270c0c4aaf015acedf)
+++ src/examples/gc_no_raii/src/tools.h	(revision 16cfd8c1c8906f3433126a396d7e0b638574cd2a)
@@ -27,5 +27,5 @@
 
 forall(otype T | has_equal(T), otype InputIterator | InputIterator_t(T, InputIterator))
-inline InputIterator find( InputIterator first, const InputIterator* const last, T val)
+static inline InputIterator find( InputIterator first, const InputIterator* const last, T val)
 {
 	while ( first != *last)
Index: src/examples/gc_no_raii/src/vector.c
===================================================================
--- src/examples/gc_no_raii/src/vector.c	(revision 8c8b614c9556d4f3da698b270c0c4aaf015acedf)
+++ src/examples/gc_no_raii/src/vector.c	(revision 16cfd8c1c8906f3433126a396d7e0b638574cd2a)
@@ -1,8 +1,10 @@
 #include "vector.h"
+
+#include <stdlib>
 
 //------------------------------------------------------------------------------
 //Initialization
 forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
-void vector_ctor(vector(T, allocator_t) *const this)
+void ctor(vector(T, allocator_t) *const this)
 {
 	ctor(&this->storage);
@@ -13,4 +15,5 @@
 void dtor(vector(T, allocator_t) *const this)
 {
+	clear(this);
 	dtor(&this->storage);
 }
@@ -55,5 +58,5 @@
 void dtor(heap_allocator(T) *const this)
 {
-	free((void*)this->storage);
+	free(this->storage);
 }
 
Index: src/examples/gc_no_raii/src/vector.h
===================================================================
--- src/examples/gc_no_raii/src/vector.h	(revision 8c8b614c9556d4f3da698b270c0c4aaf015acedf)
+++ src/examples/gc_no_raii/src/vector.h	(revision 16cfd8c1c8906f3433126a396d7e0b638574cd2a)
@@ -1,8 +1,5 @@
 #pragma once
 
-#include <assert.h>
-#include <stdbool.h>
-#include <stddef.h>
-#include <stdlib.h>
+#include <stdlib>
 
 #define DESTROY(x)
@@ -24,118 +21,117 @@
 	size_t size;
 };
-
-//------------------------------------------------------------------------------
-//Initialization
-forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
-void ctor(vector(T, allocator_t) *const this);
-
-forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
-void dtor(vector(T, allocator_t) *const this);
-
-//------------------------------------------------------------------------------
-//Capacity
-forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
-inline bool empty(vector(T, allocator_t) *const this)
-{
-	return this->size == 0;
-}
-
-forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
-inline bool size(vector(T, allocator_t) *const this)
-{
-	return this->size;
-}
-
-forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
-inline void reserve(vector(T, allocator_t) *const this, size_t size)
-{
-	realloc(&this->storage, this->size+1);
-}
-
-//------------------------------------------------------------------------------
-//Element access
-forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
-inline T at(vector(T, allocator_t) *const this, size_t index)
-{
-	// assert(index < this->size);
-	return data(&this->storage)[index];
-}
-
-forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
-inline T ?[?](vector(T, allocator_t) *const this, size_t index)
-{
-	return data(&this->storage)[index];
-}
-
-forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
-inline T front(vector(T, allocator_t) *const this)
-{
-	return data(&this->storage)[0];
-}
-
-forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
-inline T back(vector(T, allocator_t) *const this)
-{
-	return data(&this->storage)[this->size - 1];
-}
-
-//------------------------------------------------------------------------------
-//Modifiers
-forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
-void push_back(vector(T, allocator_t) *const this, T value);
-
-forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
-void pop_back(vector(T, allocator_t) *const this);
-
-forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
-void clear(vector(T, allocator_t) *const this);
-
-//------------------------------------------------------------------------------
-//Iterators
-forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
-inline T* begin(vector(T, allocator_t) *const this)
-{
-	return data(&this->storage);
-}
-
-forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
-inline const T* cbegin(const vector(T, allocator_t) *const this)
-{
-	return data(&this->storage);
-}
-
-forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
-inline T* end(vector(T, allocator_t) *const this)
-{
-	return data(&this->storage) + this->size;
-}
-
-forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
-inline const T* cend(const vector(T, allocator_t) *const this)
-{
-	return data(&this->storage) + this->size;
-}
-
-//------------------------------------------------------------------------------
-//Allocator
-forall(otype T)
-struct heap_allocator
-{
-	T* storage;
-	size_t capacity;
-};
-
-forall(otype T)
-void ctor(heap_allocator(T) *const this);
-
-forall(otype T)
-void dtor(heap_allocator(T) *const this);
-
-forall(otype T)
-void realloc(heap_allocator(T) *const this, size_t size);
-
-forall(otype T)
-inline T* data(heap_allocator(T) *const this)
-{
-	return this->storage;
-}
+//
+// //------------------------------------------------------------------------------
+// //Initialization
+// forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
+// void ctor(vector(T, allocator_t) *const this);
+//
+// forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
+// void dtor(vector(T, allocator_t) *const this);
+//
+// //------------------------------------------------------------------------------
+// //Capacity
+// forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
+// static inline bool empty(vector(T, allocator_t) *const this)
+// {
+// 	return this->size == 0;
+// }
+//
+// forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
+// static inline bool size(vector(T, allocator_t) *const this)
+// {
+// 	return this->size;
+// }
+//
+// forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
+// static inline void reserve(vector(T, allocator_t) *const this, size_t size)
+// {
+// 	realloc(&this->storage, this->size+1);
+// }
+//
+// //------------------------------------------------------------------------------
+// //Element access
+// forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
+// static inline T at(vector(T, allocator_t) *const this, size_t index)
+// {
+// 	return data(&this->storage)[index];
+// }
+//
+// forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
+// static inline T ?[?](vector(T, allocator_t) *const this, size_t index)
+// {
+// 	return data(&this->storage)[index];
+// }
+//
+// forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
+// static inline T front(vector(T, allocator_t) *const this)
+// {
+// 	return data(&this->storage)[0];
+// }
+//
+// forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
+// static inline T back(vector(T, allocator_t) *const this)
+// {
+// 	return data(&this->storage)[this->size - 1];
+// }
+//
+// //------------------------------------------------------------------------------
+// //Modifiers
+// forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
+// void push_back(vector(T, allocator_t) *const this, T value);
+//
+// forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
+// void pop_back(vector(T, allocator_t) *const this);
+//
+// forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
+// void clear(vector(T, allocator_t) *const this);
+//
+// //------------------------------------------------------------------------------
+// //Iterators
+// forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
+// static inline T* begin(vector(T, allocator_t) *const this)
+// {
+// 	return data(&this->storage);
+// }
+//
+// forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
+// static inline const T* cbegin(const vector(T, allocator_t) *const this)
+// {
+// 	return data(&this->storage);
+// }
+//
+// forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
+// static inline T* end(vector(T, allocator_t) *const this)
+// {
+// 	return data(&this->storage) + this->size;
+// }
+//
+// forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
+// static inline const T* cend(const vector(T, allocator_t) *const this)
+// {
+// 	return data(&this->storage) + this->size;
+// }
+//
+// //------------------------------------------------------------------------------
+// //Allocator
+// forall(otype T)
+// struct heap_allocator
+// {
+// 	T* storage;
+// 	size_t capacity;
+// };
+//
+// forall(otype T)
+// void ctor(heap_allocator(T) *const this);
+//
+// forall(otype T)
+// void dtor(heap_allocator(T) *const this);
+//
+// forall(otype T)
+// void realloc(heap_allocator(T) *const this, size_t size);
+//
+// forall(otype T)
+// static inline T* data(heap_allocator(T) *const this)
+// {
+// 	return this->storage;
+// }
