Index: arch/ia64/src/mm/page.c
===================================================================
--- arch/ia64/src/mm/page.c	(revision 328e0d31732c0d2a9f5b0f0376ba874e91bdbb3e)
+++ arch/ia64/src/mm/page.c	(revision 9b9e385b9726ff68e3cff0256d930903f39d0657)
@@ -90,5 +90,5 @@
 	 * Allocate VHPT and invalidate all its entries.
 	 */
-	page_ht = (pte_t *) frame_alloc(FRAME_KA, VHPT_WIDTH - FRAME_WIDTH, NULL, NULL);
+	page_ht = (pte_t *) frame_alloc(VHPT_WIDTH - FRAME_WIDTH, FRAME_KA);
 	memsetb((__address) page_ht, VHPT_SIZE, 0);
 	ht_invalidate_all();	
Index: genarch/src/mm/as_ht.c
===================================================================
--- genarch/src/mm/as_ht.c	(revision 328e0d31732c0d2a9f5b0f0376ba874e91bdbb3e)
+++ genarch/src/mm/as_ht.c	(revision 9b9e385b9726ff68e3cff0256d930903f39d0657)
@@ -54,5 +54,5 @@
 {
 	if (!page_ht) {
-		page_ht = (pte_t *) frame_alloc(FRAME_KA | FRAME_PANIC, HT_WIDTH - FRAME_WIDTH, NULL, NULL);
+		page_ht = (pte_t *) frame_alloc(HT_WIDTH - FRAME_WIDTH, FRAME_KA | FRAME_PANIC);
 		memsetb((__address) page_ht, HT_SIZE, 0);
 	}
Index: genarch/src/mm/as_pt.c
===================================================================
--- genarch/src/mm/as_pt.c	(revision 328e0d31732c0d2a9f5b0f0376ba874e91bdbb3e)
+++ genarch/src/mm/as_pt.c	(revision 9b9e385b9726ff68e3cff0256d930903f39d0657)
@@ -57,5 +57,5 @@
 	ipl_t ipl;
 
-	dst_ptl0 = (pte_t *) frame_alloc(FRAME_KA | FRAME_PANIC, ONE_FRAME, NULL, NULL);
+	dst_ptl0 = (pte_t *) frame_alloc(ONE_FRAME, FRAME_KA | FRAME_PANIC);
 
 	if (flags & FLAG_AS_KERNEL) {
Index: genarch/src/mm/page_pt.c
===================================================================
--- genarch/src/mm/page_pt.c	(revision 328e0d31732c0d2a9f5b0f0376ba874e91bdbb3e)
+++ genarch/src/mm/page_pt.c	(revision 9b9e385b9726ff68e3cff0256d930903f39d0657)
@@ -66,5 +66,5 @@
 
 	if (GET_PTL1_FLAGS(ptl0, PTL0_INDEX(page)) & PAGE_NOT_PRESENT) {
-		newpt = frame_alloc(FRAME_KA, ONE_FRAME, NULL, NULL);
+		newpt = frame_alloc(ONE_FRAME, FRAME_KA);
 		memsetb(newpt, PAGE_SIZE, 0);
 		SET_PTL1_ADDRESS(ptl0, PTL0_INDEX(page), KA2PA(newpt));
@@ -75,5 +75,5 @@
 
 	if (GET_PTL2_FLAGS(ptl1, PTL1_INDEX(page)) & PAGE_NOT_PRESENT) {
-		newpt = frame_alloc(FRAME_KA, ONE_FRAME, NULL, NULL);
+		newpt = frame_alloc(ONE_FRAME, FRAME_KA);
 		memsetb(newpt, PAGE_SIZE, 0);
 		SET_PTL2_ADDRESS(ptl1, PTL1_INDEX(page), KA2PA(newpt));
@@ -84,5 +84,5 @@
 
 	if (GET_PTL3_FLAGS(ptl2, PTL2_INDEX(page)) & PAGE_NOT_PRESENT) {
-		newpt = frame_alloc(FRAME_KA, ONE_FRAME, NULL, NULL);
+		newpt = frame_alloc(ONE_FRAME, FRAME_KA);
 		memsetb(newpt, PAGE_SIZE, 0);
 		SET_PTL3_ADDRESS(ptl2, PTL2_INDEX(page), KA2PA(newpt));
Index: generic/include/mm/frame.h
===================================================================
--- generic/include/mm/frame.h	(revision 328e0d31732c0d2a9f5b0f0376ba874e91bdbb3e)
+++ generic/include/mm/frame.h	(revision 9b9e385b9726ff68e3cff0256d930903f39d0657)
@@ -62,4 +62,8 @@
 #define ZONE_BLACKLIST_SIZE	8
 
+#define frame_alloc(order, flags)				frame_alloc_generic(order, flags, NULL, NULL)
+#define frame_alloc_rc(order, flags, status)			frame_alloc_generic(order, flags, status, NULL)
+#define frame_alloc_rc_zone(order, flags, status, zone)		frame_alloc_generic(order, flags, status, zone)
+
 struct zone {
 	link_t link;		/**< link to previous and next zone */
@@ -102,5 +106,7 @@
 extern void frame_initialize(frame_t *frame, zone_t *zone);
 
-__address frame_alloc(int flags, __u8 order, int * status, zone_t **pzone);
+__address frame_alloc_generic(__u8 order, int flags, int * status, zone_t **pzone);
+
+
 extern void frame_free(__address addr);
 
Index: generic/src/cpu/cpu.c
===================================================================
--- generic/src/cpu/cpu.c	(revision 328e0d31732c0d2a9f5b0f0376ba874e91bdbb3e)
+++ generic/src/cpu/cpu.c	(revision 9b9e385b9726ff68e3cff0256d930903f39d0657)
@@ -62,5 +62,5 @@
 
 		for (i=0; i < config.cpu_count; i++) {
-			cpus[i].stack = (__u8 *) frame_alloc(FRAME_KA | FRAME_PANIC, ONE_FRAME, NULL, NULL);
+			cpus[i].stack = (__u8 *) frame_alloc(ONE_FRAME, FRAME_KA | FRAME_PANIC);
 			
 			cpus[i].id = i;
Index: generic/src/mm/as.c
===================================================================
--- generic/src/mm/as.c	(revision 328e0d31732c0d2a9f5b0f0376ba874e91bdbb3e)
+++ generic/src/mm/as.c	(revision 9b9e385b9726ff68e3cff0256d930903f39d0657)
@@ -257,5 +257,5 @@
 	 *   the different causes
 	 */
-	frame = frame_alloc(0, ONE_FRAME, NULL, NULL);
+	frame = frame_alloc(ONE_FRAME, 0);
 	memsetb(PA2KA(frame), FRAME_SIZE, 0);
 	
Index: generic/src/mm/frame.c
===================================================================
--- generic/src/mm/frame.c	(revision 328e0d31732c0d2a9f5b0f0376ba874e91bdbb3e)
+++ generic/src/mm/frame.c	(revision 9b9e385b9726ff68e3cff0256d930903f39d0657)
@@ -110,5 +110,5 @@
  * @return Allocated frame.
  */
-__address frame_alloc(int flags, __u8 order, int * status, zone_t **pzone) 
+__address frame_alloc_generic(__u8 order, int flags, int * status, zone_t **pzone) 
 {
 	ipl_t ipl;
Index: generic/src/mm/slab.c
===================================================================
--- generic/src/mm/slab.c	(revision 328e0d31732c0d2a9f5b0f0376ba874e91bdbb3e)
+++ generic/src/mm/slab.c	(revision 9b9e385b9726ff68e3cff0256d930903f39d0657)
@@ -156,5 +156,5 @@
 	frame_t *frame;
 
-	data = (void *)frame_alloc(FRAME_KA | flags, cache->order, &status, &zone);
+	data = (void *)frame_alloc_rc_zone(cache->order, FRAME_KA | flags, &status, &zone);
 	if (status != FRAME_OK) {
 		return NULL;
Index: generic/src/proc/thread.c
===================================================================
--- generic/src/proc/thread.c	(revision 328e0d31732c0d2a9f5b0f0376ba874e91bdbb3e)
+++ generic/src/proc/thread.c	(revision 9b9e385b9726ff68e3cff0256d930903f39d0657)
@@ -167,7 +167,7 @@
 		spinlock_initialize(&t->lock, "thread_t_lock");
 	
-		frame_ks = frame_alloc(FRAME_KA, ONE_FRAME, NULL, NULL);
+		frame_ks = frame_alloc(ONE_FRAME, FRAME_KA);
 		if (THREAD_USER_STACK & flags) {
-			frame_us = frame_alloc(FRAME_KA, ONE_FRAME, NULL,NULL);
+			frame_us = frame_alloc(ONE_FRAME, FRAME_KA);
 		}
 
Index: test/mm/falloc1/test.c
===================================================================
--- test/mm/falloc1/test.c	(revision 328e0d31732c0d2a9f5b0f0376ba874e91bdbb3e)
+++ test/mm/falloc1/test.c	(revision 9b9e385b9726ff68e3cff0256d930903f39d0657)
@@ -56,5 +56,5 @@
 			allocated = 0;
 			for (i = 0; i < MAX_FRAMES >> order; i++) {
-				frames[allocated] = frame_alloc(FRAME_ATOMIC | FRAME_KA, order, &status, NULL);
+				frames[allocated] = frame_alloc_rc(order, FRAME_ATOMIC | FRAME_KA, &status);
 				
 				if (ALIGN_UP(frames[allocated], FRAME_SIZE << order) != frames[allocated]) {
Index: test/mm/falloc2/test.c
===================================================================
--- test/mm/falloc2/test.c	(revision 328e0d31732c0d2a9f5b0f0376ba874e91bdbb3e)
+++ test/mm/falloc2/test.c	(revision 9b9e385b9726ff68e3cff0256d930903f39d0657)
@@ -61,8 +61,8 @@
 	for (run = 0; run < THREAD_RUNS; run++) {
 		for (order = 0; order <= MAX_ORDER; order++) {
-			printf("Thread #%d: Allocating %d frames blocks ... \n", THREAD->tid, 1 << order);
+			printf("Thread #%d (cpu%d): Allocating %d frames blocks ... \n", THREAD->tid, CPU->id, 1 << order);
 			allocated = 0;
 			for (i = 0; i < (MAX_FRAMES >> order); i++) {
-				frames[allocated] = frame_alloc(FRAME_ATOMIC | FRAME_KA, order, &status, NULL);
+				frames[allocated] = frame_alloc_rc(order, FRAME_ATOMIC | FRAME_KA, &status);
 				if (status == 0) {
 					memsetb(frames[allocated], FRAME_SIZE << order, val);
@@ -72,11 +72,11 @@
 				}
 			}
-			printf("Thread #%d: %d blocks allocated.\n", THREAD->tid, allocated);
+			printf("Thread #%d (cpu%d): %d blocks allocated.\n", THREAD->tid, CPU->id, allocated);
 
-			printf("Thread #%d: Deallocating ... \n", THREAD->tid);
+			printf("Thread #%d (cpu%d): Deallocating ... \n", THREAD->tid, CPU->id);
 			for (i = 0; i < allocated; i++) {
 				for (k = 0; k <= ((FRAME_SIZE << order) - 1); k++) {
 					if (((__u8 *) frames[i])[k] != val) {
-						printf("Thread #%d: Unexpected data (%d) in block %P offset %X\n", THREAD->tid, ((char *) frames[i])[k], frames[i], k);
+						printf("Thread #%d (cpu%d): Unexpected data (%d) in block %P offset %X\n", THREAD->tid, CPU->id, ((char *) frames[i])[k], frames[i], k);
 						failed();
 					}
@@ -84,10 +84,10 @@
 				frame_free(frames[i]);
 			}
-			printf("Thread #%d: Finished run.\n", val);
+			printf("Thread #%d (cpu%d): Finished run.\n", THREAD->tid, CPU->id);
 		}
 	}
 	
 	free(frames);
-	
+	printf("Thread #%d (cpu%d): Exiting\n", THREAD->tid, CPU->id);
 	atomic_dec(&thread_count);
 }
Index: test/mm/mapping1/test.c
===================================================================
--- test/mm/mapping1/test.c	(revision 328e0d31732c0d2a9f5b0f0376ba874e91bdbb3e)
+++ test/mm/mapping1/test.c	(revision 9b9e385b9726ff68e3cff0256d930903f39d0657)
@@ -48,6 +48,6 @@
 	printf("Memory management test mapping #1\n");
 
-	frame0 = frame_alloc(FRAME_KA, ONE_FRAME, NULL, NULL);
-	frame1 = frame_alloc(FRAME_KA, ONE_FRAME, NULL, NULL);	
+	frame0 = frame_alloc(ONE_FRAME, FRAME_KA);
+	frame1 = frame_alloc(ONE_FRAME, FRAME_KA);	
 
 	printf("Writing %L to physical address %P.\n", VALUE0, KA2PA(frame0));
