Index: arch/mips32/src/mm/frame.c
===================================================================
--- arch/mips32/src/mm/frame.c	(revision 77147d661d2618164797b94b11103b201453bdc9)
+++ arch/mips32/src/mm/frame.c	(revision 5d2ab231a2e6c513f459e864da1c59750cce6db7)
@@ -51,4 +51,4 @@
 	else
 		zone_create_in_region(KA2PA(KERNEL_LOAD_ADDRESS),
-				      config.memory_size & ~(FRAME_SIZE-1));
+				      (config.memory_size & ~(FRAME_SIZE-1)));
 }
Index: generic/include/mm/frame.h
===================================================================
--- generic/include/mm/frame.h	(revision 77147d661d2618164797b94b11103b201453bdc9)
+++ generic/include/mm/frame.h	(revision 5d2ab231a2e6c513f459e864da1c59750cce6db7)
@@ -50,8 +50,11 @@
 #define ADDR2FRAME(zone, addr)			(&((zone)->frames[((addr) - (zone)->base) / FRAME_SIZE]))
 #define FRAME_INDEX(zone, frame)		((index_t)((frame) - (zone)->frames))
+#define FRAME_INDEX_ABS(zone, frame)		(((index_t)((frame) - (zone)->frames)) + (zone)->base_index)
 #define FRAME_INDEX_VALID(zone, index)		(((index) >= 0) && ((index) < ((zone)->free_count + (zone)->busy_count)))
 #define IS_BUDDY_ORDER_OK(index, order)		((~(((__native) -1) << (order)) & (index)) == 0)
 #define IS_BUDDY_LEFT_BLOCK(zone, frame)	(((FRAME_INDEX((zone), (frame)) >> (frame)->buddy_order) & 0x1) == 0)
 #define IS_BUDDY_RIGHT_BLOCK(zone, frame)	(((FRAME_INDEX((zone), (frame)) >> (frame)->buddy_order) & 0x1) == 1)
+#define IS_BUDDY_LEFT_BLOCK_ABS(zone, frame)	(((FRAME_INDEX_ABS((zone), (frame)) >> (frame)->buddy_order) & 0x1) == 0)
+#define IS_BUDDY_RIGHT_BLOCK_ABS(zone, frame)	(((FRAME_INDEX_ABS((zone), (frame)) >> (frame)->buddy_order) & 0x1) == 1)
 
 #define ZONE_BLACKLIST_SIZE	4
@@ -62,4 +65,5 @@
 	SPINLOCK_DECLARE(lock);	/**< this lock protects everything below */
 	__address base;		/**< physical address of the first frame in the frames array */
+	index_t base_index;	/**< frame index offset of the zone base */
 	frame_t *frames;	/**< array of frame_t structures in this zone */
 	count_t free_count;	/**< number of free frame_t structures */
Index: generic/src/main/main.c
===================================================================
--- generic/src/main/main.c	(revision 77147d661d2618164797b94b11103b201453bdc9)
+++ generic/src/main/main.c	(revision 5d2ab231a2e6c513f459e864da1c59750cce6db7)
@@ -123,5 +123,5 @@
 	
 	context_save(&ctx);
-	context_set(&ctx, FADDR(main_bsp_separated_stack), config.base + config.kernel_size, CONFIG_STACK_SIZE);
+	context_set(&ctx, FADDR(main_bsp_separated_stack), config.base + config.kernel_size - CONFIG_STACK_SIZE, CONFIG_STACK_SIZE);
 	context_restore(&ctx);
 	/* not reached */
Index: generic/src/mm/frame.c
===================================================================
--- generic/src/mm/frame.c	(revision 77147d661d2618164797b94b11103b201453bdc9)
+++ generic/src/mm/frame.c	(revision 5d2ab231a2e6c513f459e864da1c59750cce6db7)
@@ -134,5 +134,4 @@
 	}
 		
-
 	/* Allocate frames from zone buddy system */
 	tmp = buddy_system_alloc(zone->buddy_system, order);
@@ -161,5 +160,4 @@
 		*status = FRAME_OK;
 	}
-	
 	return v;
 }
@@ -180,4 +178,6 @@
 	zone_t *zone = NULL;
 	frame_t *frame;
+	int order;
+	
 	ASSERT(addr % FRAME_SIZE == 0);
 	
@@ -210,4 +210,7 @@
 	
 	frame = ADDR2FRAME(zone, addr);
+	
+	/* remember frame order */
+	order = frame->buddy_order;
 
 	ASSERT(frame->refcount);
@@ -218,6 +221,6 @@
 
 	/* Update zone information. */
-	zone->free_count += (1 << frame->buddy_order);
-	zone->busy_count -= (1 << frame->buddy_order);
+	zone->free_count += (1 << order);
+	zone->busy_count -= (1 << order);
 	
 	spinlock_unlock(&zone->lock);
@@ -322,4 +325,6 @@
 	
 		z->base = start;
+		z->base_index = start / FRAME_SIZE;
+		
 		z->flags = flags;
 
@@ -349,4 +354,5 @@
 			buddy_system_free(z->buddy_system, &z->frames[i].buddy_link);	
 		}
+		
 	}
 	return z;
@@ -401,9 +407,9 @@
 	frame = list_get_instance(block, frame_t, buddy_link);
 	zone = (zone_t *) b->data;
-	
-	ASSERT(IS_BUDDY_ORDER_OK(FRAME_INDEX(zone, frame), frame->buddy_order));
-	
-	is_left = IS_BUDDY_LEFT_BLOCK(zone, frame);
-	is_right = IS_BUDDY_RIGHT_BLOCK(zone, frame);
+	ASSERT(IS_BUDDY_ORDER_OK(FRAME_INDEX_ABS(zone, frame), frame->buddy_order));
+	
+	
+	is_left = IS_BUDDY_LEFT_BLOCK_ABS(zone, frame);
+	is_right = IS_BUDDY_RIGHT_BLOCK_ABS(zone, frame);
 	
 	ASSERT(is_left ^ is_right);
Index: test/mm/falloc1/test.c
===================================================================
--- test/mm/falloc1/test.c	(revision 77147d661d2618164797b94b11103b201453bdc9)
+++ test/mm/falloc1/test.c	(revision 5d2ab231a2e6c513f459e864da1c59750cce6db7)
@@ -34,5 +34,5 @@
 #include <debug.h>
 
-#define MAX_FRAMES 1024
+#define MAX_FRAMES 2048
 #define MAX_ORDER 8
 #define TEST_RUNS 4
@@ -53,5 +53,10 @@
 			allocated = 0;
 			for (i=0;i<MAX_FRAMES>>order;i++) {
-				frames[allocated] = frame_alloc(FRAME_NON_BLOCKING,order, &status);
+				frames[allocated] = frame_alloc(FRAME_NON_BLOCKING, order, &status);
+				
+				if (frames[allocated] % (FRAME_SIZE << order) != 0) {
+					panic("Test failed. Block at address %X (size %dK) is not aligned\n", frames[allocated], (FRAME_SIZE << order) >> 10);
+				}
+				
 				if (status == 0) {
 					allocated++;
