Index: kernel/generic/src/adt/bitmap.c
===================================================================
--- kernel/generic/src/adt/bitmap.c	(revision 6f4495f5c6915097f277fabc29a874343f77e88a)
+++ kernel/generic/src/adt/bitmap.c	(revision 0b3a78fec9fcd0f2d1ba2ad32efec95c4ad2cfdf)
@@ -39,5 +39,4 @@
 
 #include <adt/bitmap.h>
-#include <typedefs.h>
 #include <arch/types.h>
 #include <align.h>
Index: kernel/generic/src/adt/btree.c
===================================================================
--- kernel/generic/src/adt/btree.c	(revision 6f4495f5c6915097f277fabc29a874343f77e88a)
+++ kernel/generic/src/adt/btree.c	(revision 0b3a78fec9fcd0f2d1ba2ad32efec95c4ad2cfdf)
@@ -52,5 +52,4 @@
 #include <debug.h>
 #include <panic.h>
-#include <typedefs.h>
 #include <print.h>
 
Index: kernel/generic/src/adt/hash_table.c
===================================================================
--- kernel/generic/src/adt/hash_table.c	(revision 6f4495f5c6915097f277fabc29a874343f77e88a)
+++ kernel/generic/src/adt/hash_table.c	(revision 0b3a78fec9fcd0f2d1ba2ad32efec95c4ad2cfdf)
@@ -40,5 +40,4 @@
 #include <adt/hash_table.h>
 #include <adt/list.h>
-#include <typedefs.h>
 #include <arch/types.h>
 #include <debug.h>
Index: kernel/generic/src/console/cmd.c
===================================================================
--- kernel/generic/src/console/cmd.c	(revision 6f4495f5c6915097f277fabc29a874343f77e88a)
+++ kernel/generic/src/console/cmd.c	(revision 0b3a78fec9fcd0f2d1ba2ad32efec95c4ad2cfdf)
@@ -46,5 +46,4 @@
 #include <print.h>
 #include <panic.h>
-#include <typedefs.h>
 #include <arch/types.h>
 #include <adt/list.h>
Index: kernel/generic/src/console/console.c
===================================================================
--- kernel/generic/src/console/console.c	(revision 6f4495f5c6915097f277fabc29a874343f77e88a)
+++ kernel/generic/src/console/console.c	(revision 0b3a78fec9fcd0f2d1ba2ad32efec95c4ad2cfdf)
@@ -39,5 +39,4 @@
 #include <synch/spinlock.h>
 #include <arch/types.h>
-#include <typedefs.h>
 #include <arch.h>
 #include <func.h>
Index: kernel/generic/src/console/kconsole.c
===================================================================
--- kernel/generic/src/console/kconsole.c	(revision 6f4495f5c6915097f277fabc29a874343f77e88a)
+++ kernel/generic/src/console/kconsole.c	(revision 0b3a78fec9fcd0f2d1ba2ad32efec95c4ad2cfdf)
@@ -44,5 +44,4 @@
 #include <print.h>
 #include <panic.h>
-#include <typedefs.h>
 #include <arch/types.h>
 #include <adt/list.h>
Index: kernel/generic/src/cpu/cpu.c
===================================================================
--- kernel/generic/src/cpu/cpu.c	(revision 6f4495f5c6915097f277fabc29a874343f77e88a)
+++ kernel/generic/src/cpu/cpu.c	(revision 0b3a78fec9fcd0f2d1ba2ad32efec95c4ad2cfdf)
@@ -45,5 +45,4 @@
 #include <config.h>
 #include <panic.h>
-#include <typedefs.h>
 #include <memstr.h>
 #include <adt/list.h>
Index: kernel/generic/src/ddi/device.c
===================================================================
--- kernel/generic/src/ddi/device.c	(revision 6f4495f5c6915097f277fabc29a874343f77e88a)
+++ kernel/generic/src/ddi/device.c	(revision 0b3a78fec9fcd0f2d1ba2ad32efec95c4ad2cfdf)
@@ -39,5 +39,4 @@
 #include <atomic.h>
 #include <debug.h>
-#include <typedefs.h>
 
 static atomic_t last;
Index: kernel/generic/src/ddi/irq.c
===================================================================
--- kernel/generic/src/ddi/irq.c	(revision 6f4495f5c6915097f277fabc29a874343f77e88a)
+++ kernel/generic/src/ddi/irq.c	(revision 0b3a78fec9fcd0f2d1ba2ad32efec95c4ad2cfdf)
@@ -70,5 +70,4 @@
 #include <adt/hash_table.h>
 #include <arch/types.h>
-#include <typedefs.h>
 #include <synch/spinlock.h>
 #include <arch.h>
Index: kernel/generic/src/debug/symtab.c
===================================================================
--- kernel/generic/src/debug/symtab.c	(revision 6f4495f5c6915097f277fabc29a874343f77e88a)
+++ kernel/generic/src/debug/symtab.c	(revision 0b3a78fec9fcd0f2d1ba2ad32efec95c4ad2cfdf)
@@ -37,5 +37,4 @@
 
 #include <symtab.h>
-#include <typedefs.h>
 #include <arch/byteorder.h>
 #include <func.h>
Index: kernel/generic/src/lib/elf.c
===================================================================
--- kernel/generic/src/lib/elf.c	(revision 6f4495f5c6915097f277fabc29a874343f77e88a)
+++ kernel/generic/src/lib/elf.c	(revision 0b3a78fec9fcd0f2d1ba2ad32efec95c4ad2cfdf)
@@ -40,5 +40,4 @@
 #include <debug.h>
 #include <arch/types.h>
-#include <typedefs.h>
 #include <mm/as.h>
 #include <mm/frame.h>
Index: kernel/generic/src/lib/func.c
===================================================================
--- kernel/generic/src/lib/func.c	(revision 6f4495f5c6915097f277fabc29a874343f77e88a)
+++ kernel/generic/src/lib/func.c	(revision 0b3a78fec9fcd0f2d1ba2ad32efec95c4ad2cfdf)
@@ -41,5 +41,4 @@
 #include <arch/asm.h>
 #include <arch.h>
-#include <typedefs.h>
 #include <console/kconsole.h>
 
Index: kernel/generic/src/main/kinit.c
===================================================================
--- kernel/generic/src/main/kinit.c	(revision 6f4495f5c6915097f277fabc29a874343f77e88a)
+++ kernel/generic/src/main/kinit.c	(revision 0b3a78fec9fcd0f2d1ba2ad32efec95c4ad2cfdf)
@@ -63,4 +63,5 @@
 #include <security/cap.h>
 #include <lib/rd.h>
+#include <ipc/ipc.h>
 
 #ifdef CONFIG_SMP
Index: kernel/generic/src/main/main.c
===================================================================
--- kernel/generic/src/main/main.c	(revision 6f4495f5c6915097f277fabc29a874343f77e88a)
+++ kernel/generic/src/main/main.c	(revision 0b3a78fec9fcd0f2d1ba2ad32efec95c4ad2cfdf)
@@ -54,4 +54,5 @@
 #include <config.h>
 #include <time/clock.h>
+#include <time/timeout.h>
 #include <proc/scheduler.h>
 #include <proc/thread.h>
@@ -75,5 +76,4 @@
 #include <arch.h>
 #include <arch/faddr.h>
-#include <typedefs.h>
 #include <ipc/ipc.h>
 #include <macros.h>
Index: kernel/generic/src/mm/as.c
===================================================================
--- kernel/generic/src/mm/as.c	(revision 6f4495f5c6915097f277fabc29a874343f77e88a)
+++ kernel/generic/src/mm/as.c	(revision 0b3a78fec9fcd0f2d1ba2ad32efec95c4ad2cfdf)
@@ -75,5 +75,4 @@
 #include <align.h>
 #include <arch/types.h>
-#include <typedefs.h>
 #include <syscall/copy.h>
 #include <arch/interrupt.h>
@@ -169,5 +168,9 @@
 	as->refcount = 0;
 	as->cpu_refcount = 0;
+#ifdef AS_PAGE_TABLE
 	as->page_table = page_table_create(flags);
+#else
+	page_table_create(flags);
+#endif
 
 	return as;
@@ -217,5 +220,9 @@
 
 	btree_destroy(&as->as_area_btree);
+#ifdef AS_PAGE_TABLE
 	page_table_destroy(as->page_table);
+#else
+	page_table_destroy(NULL);
+#endif
 
 	interrupts_restore(ipl);
Index: kernel/generic/src/mm/backend_anon.c
===================================================================
--- kernel/generic/src/mm/backend_anon.c	(revision 6f4495f5c6915097f277fabc29a874343f77e88a)
+++ kernel/generic/src/mm/backend_anon.c	(revision 0b3a78fec9fcd0f2d1ba2ad32efec95c4ad2cfdf)
@@ -48,5 +48,4 @@
 #include <errno.h>
 #include <arch/types.h>
-#include <typedefs.h>
 #include <align.h>
 #include <arch.h>
Index: kernel/generic/src/mm/backend_elf.c
===================================================================
--- kernel/generic/src/mm/backend_elf.c	(revision 6f4495f5c6915097f277fabc29a874343f77e88a)
+++ kernel/generic/src/mm/backend_elf.c	(revision 0b3a78fec9fcd0f2d1ba2ad32efec95c4ad2cfdf)
@@ -39,5 +39,4 @@
 #include <debug.h>
 #include <arch/types.h>
-#include <typedefs.h>
 #include <mm/as.h>
 #include <mm/frame.h>
Index: kernel/generic/src/mm/backend_phys.c
===================================================================
--- kernel/generic/src/mm/backend_phys.c	(revision 6f4495f5c6915097f277fabc29a874343f77e88a)
+++ kernel/generic/src/mm/backend_phys.c	(revision 0b3a78fec9fcd0f2d1ba2ad32efec95c4ad2cfdf)
@@ -38,5 +38,4 @@
 #include <debug.h>
 #include <arch/types.h>
-#include <typedefs.h>
 #include <mm/as.h>
 #include <mm/frame.h>
Index: kernel/generic/src/mm/buddy.c
===================================================================
--- kernel/generic/src/mm/buddy.c	(revision 6f4495f5c6915097f277fabc29a874343f77e88a)
+++ kernel/generic/src/mm/buddy.c	(revision 0b3a78fec9fcd0f2d1ba2ad32efec95c4ad2cfdf)
@@ -43,6 +43,4 @@
 #include <mm/frame.h>
 #include <arch/types.h>
-#include <typedefs.h>
-#include <adt/list.h>
 #include <debug.h>
 #include <print.h>
Index: kernel/generic/src/mm/frame.c
===================================================================
--- kernel/generic/src/mm/frame.c	(revision 6f4495f5c6915097f277fabc29a874343f77e88a)
+++ kernel/generic/src/mm/frame.c	(revision 0b3a78fec9fcd0f2d1ba2ad32efec95c4ad2cfdf)
@@ -52,5 +52,4 @@
  */
 
-#include <typedefs.h>
 #include <arch/types.h>
 #include <mm/frame.h>
Index: kernel/generic/src/mm/page.c
===================================================================
--- kernel/generic/src/mm/page.c	(revision 6f4495f5c6915097f277fabc29a874343f77e88a)
+++ kernel/generic/src/mm/page.c	(revision 0b3a78fec9fcd0f2d1ba2ad32efec95c4ad2cfdf)
@@ -47,5 +47,4 @@
 #include <mm/frame.h>
 #include <arch/types.h>
-#include <typedefs.h>
 #include <arch/asm.h>
 #include <memstr.h>
Index: kernel/generic/src/mm/tlb.c
===================================================================
--- kernel/generic/src/mm/tlb.c	(revision 6f4495f5c6915097f277fabc29a874343f77e88a)
+++ kernel/generic/src/mm/tlb.c	(revision 0b3a78fec9fcd0f2d1ba2ad32efec95c4ad2cfdf)
@@ -45,5 +45,4 @@
 #include <smp/ipi.h>
 #include <synch/spinlock.h>
-#include <typedefs.h>
 #include <atomic.h>
 #include <arch/interrupt.h>
@@ -52,4 +51,5 @@
 #include <panic.h>
 #include <debug.h>
+#include <cpu.h>
 
 /**
Index: kernel/generic/src/proc/scheduler.c
===================================================================
--- kernel/generic/src/proc/scheduler.c	(revision 6f4495f5c6915097f277fabc29a874343f77e88a)
+++ kernel/generic/src/proc/scheduler.c	(revision 0b3a78fec9fcd0f2d1ba2ad32efec95c4ad2cfdf)
@@ -45,4 +45,5 @@
 #include <mm/page.h>
 #include <mm/as.h>
+#include <time/timeout.h>
 #include <time/delay.h>
 #include <arch/asm.h>
@@ -53,9 +54,9 @@
 #include <config.h>
 #include <context.h>
+#include <fpu_context.h>
 #include <func.h>
 #include <arch.h>
 #include <adt/list.h>
 #include <panic.h>
-#include <typedefs.h>
 #include <cpu.h>
 #include <print.h>
Index: kernel/generic/src/proc/task.c
===================================================================
--- kernel/generic/src/proc/task.c	(revision 6f4495f5c6915097f277fabc29a874343f77e88a)
+++ kernel/generic/src/proc/task.c	(revision 0b3a78fec9fcd0f2d1ba2ad32efec95c4ad2cfdf)
@@ -364,5 +364,5 @@
 		
 		if (sleeping)
-			waitq_interrupt_sleep(thr);
+			thread_interrupt_sleep(thr);
 	}
 	
Index: kernel/generic/src/proc/the.c
===================================================================
--- kernel/generic/src/proc/the.c	(revision 6f4495f5c6915097f277fabc29a874343f77e88a)
+++ kernel/generic/src/proc/the.c	(revision 0b3a78fec9fcd0f2d1ba2ad32efec95c4ad2cfdf)
@@ -43,5 +43,4 @@
 
 #include <arch.h>
-#include <typedefs.h>
 
 
Index: kernel/generic/src/proc/thread.c
===================================================================
--- kernel/generic/src/proc/thread.c	(revision 6f4495f5c6915097f277fabc29a874343f77e88a)
+++ kernel/generic/src/proc/thread.c	(revision 0b3a78fec9fcd0f2d1ba2ad32efec95c4ad2cfdf)
@@ -54,6 +54,6 @@
 #include <adt/btree.h>
 #include <adt/list.h>
-#include <typedefs.h>
 #include <time/clock.h>
+#include <time/timeout.h>
 #include <config.h>
 #include <arch/interrupt.h>
@@ -679,4 +679,57 @@
 }
 
+/** Interrupt sleeping thread.
+ *
+ * This routine attempts to interrupt a thread from its sleep in a waitqueue.
+ * If the thread is not found sleeping, no action is taken.
+ *
+ * @param t Thread to be interrupted.
+ */
+void thread_interrupt_sleep(thread_t *t)
+{
+	waitq_t *wq;
+	bool do_wakeup = false;
+	ipl_t ipl;
+
+	ipl = interrupts_disable();
+	spinlock_lock(&threads_lock);
+	if (!thread_exists(t))
+		goto out;
+
+grab_locks:
+	spinlock_lock(&t->lock);
+	if ((wq = t->sleep_queue)) {		/* assignment */
+		if (!(t->sleep_interruptible)) {
+			/*
+			 * The sleep cannot be interrupted.
+			 */
+			spinlock_unlock(&t->lock);
+			goto out;
+		}
+			
+		if (!spinlock_trylock(&wq->lock)) {
+			spinlock_unlock(&t->lock);
+			goto grab_locks;	/* avoid deadlock */
+		}
+
+		if (t->timeout_pending && timeout_unregister(&t->sleep_timeout))
+			t->timeout_pending = false;
+
+		list_remove(&t->wq_link);
+		t->saved_context = t->sleep_interruption_context;
+		do_wakeup = true;
+		t->sleep_queue = NULL;
+		spinlock_unlock(&wq->lock);
+	}
+	spinlock_unlock(&t->lock);
+
+	if (do_wakeup)
+		thread_ready(t);
+
+out:
+	spinlock_unlock(&threads_lock);
+	interrupts_restore(ipl);
+}
+
 /** @}
  */
Index: kernel/generic/src/security/cap.c
===================================================================
--- kernel/generic/src/security/cap.c	(revision 6f4495f5c6915097f277fabc29a874343f77e88a)
+++ kernel/generic/src/security/cap.c	(revision 0b3a78fec9fcd0f2d1ba2ad32efec95c4ad2cfdf)
@@ -44,5 +44,4 @@
 #include <syscall/copy.h>
 #include <arch.h>
-#include <typedefs.h>
 #include <errno.h>
 
Index: kernel/generic/src/synch/condvar.c
===================================================================
--- kernel/generic/src/synch/condvar.c	(revision 6f4495f5c6915097f277fabc29a874343f77e88a)
+++ kernel/generic/src/synch/condvar.c	(revision 0b3a78fec9fcd0f2d1ba2ad32efec95c4ad2cfdf)
@@ -41,5 +41,4 @@
 #include <synch/synch.h>
 #include <arch.h>
-#include <typedefs.h>
 
 /** Initialize condition variable.
Index: kernel/generic/src/synch/rwlock.c
===================================================================
--- kernel/generic/src/synch/rwlock.c	(revision 6f4495f5c6915097f277fabc29a874343f77e88a)
+++ kernel/generic/src/synch/rwlock.c	(revision 0b3a78fec9fcd0f2d1ba2ad32efec95c4ad2cfdf)
@@ -64,5 +64,4 @@
 #include <synch/synch.h>
 #include <adt/list.h>
-#include <typedefs.h>
 #include <arch/asm.h>
 #include <arch.h>
Index: kernel/generic/src/synch/waitq.c
===================================================================
--- kernel/generic/src/synch/waitq.c	(revision 6f4495f5c6915097f277fabc29a874343f77e88a)
+++ kernel/generic/src/synch/waitq.c	(revision 0b3a78fec9fcd0f2d1ba2ad32efec95c4ad2cfdf)
@@ -50,5 +50,4 @@
 #include <arch/asm.h>
 #include <arch/types.h>
-#include <typedefs.h>
 #include <time/timeout.h>
 #include <arch.h>
@@ -118,56 +117,4 @@
 }
 
-/** Interrupt sleeping thread.
- *
- * This routine attempts to interrupt a thread from its sleep in a waitqueue.
- * If the thread is not found sleeping, no action is taken.
- *
- * @param t Thread to be interrupted.
- */
-void waitq_interrupt_sleep(thread_t *t)
-{
-	waitq_t *wq;
-	bool do_wakeup = false;
-	ipl_t ipl;
-
-	ipl = interrupts_disable();
-	spinlock_lock(&threads_lock);
-	if (!thread_exists(t))
-		goto out;
-
-grab_locks:
-	spinlock_lock(&t->lock);
-	if ((wq = t->sleep_queue)) {		/* assignment */
-		if (!(t->sleep_interruptible)) {
-			/*
-			 * The sleep cannot be interrupted.
-			 */
-			spinlock_unlock(&t->lock);
-			goto out;
-		}
-			
-		if (!spinlock_trylock(&wq->lock)) {
-			spinlock_unlock(&t->lock);
-			goto grab_locks;	/* avoid deadlock */
-		}
-
-		if (t->timeout_pending && timeout_unregister(&t->sleep_timeout))
-			t->timeout_pending = false;
-
-		list_remove(&t->wq_link);
-		t->saved_context = t->sleep_interruption_context;
-		do_wakeup = true;
-		t->sleep_queue = NULL;
-		spinlock_unlock(&wq->lock);
-	}
-	spinlock_unlock(&t->lock);
-
-	if (do_wakeup)
-		thread_ready(t);
-
-out:
-	spinlock_unlock(&threads_lock);
-	interrupts_restore(ipl);
-}
 
 /** Sleep until either wakeup, timeout or interruption occurs
@@ -426,5 +373,5 @@
 	 * (the link belongs to the wait queue), but because
 	 * of synchronization with waitq_timeouted_sleep()
-	 * and waitq_interrupt_sleep().
+	 * and thread_interrupt_sleep().
 	 *
 	 * In order for these two functions to work, the following
Index: kernel/generic/src/syscall/copy.c
===================================================================
--- kernel/generic/src/syscall/copy.c	(revision 6f4495f5c6915097f277fabc29a874343f77e88a)
+++ kernel/generic/src/syscall/copy.c	(revision 0b3a78fec9fcd0f2d1ba2ad32efec95c4ad2cfdf)
@@ -45,5 +45,4 @@
 #include <arch.h>
 #include <errno.h>
-#include <typedefs.h>
 
 /** Copy data from userspace to kernel.
Index: kernel/generic/src/time/timeout.c
===================================================================
--- kernel/generic/src/time/timeout.c	(revision 6f4495f5c6915097f277fabc29a874343f77e88a)
+++ kernel/generic/src/time/timeout.c	(revision 0b3a78fec9fcd0f2d1ba2ad32efec95c4ad2cfdf)
@@ -37,5 +37,4 @@
 
 #include <time/timeout.h>
-#include <typedefs.h>
 #include <arch/types.h>
 #include <config.h>
