diff --git a/core/kernel_init.c b/core/kernel_init.c
index dca0b45c94366d74ffe1f098cbde259f456a8f00..39d3e660948c0592c1ebace2b4f5436c3d00177a 100644
--- a/core/kernel_init.c
+++ b/core/kernel_init.c
@@ -76,7 +76,7 @@ void kernel_init(void)
     
     sched_init();
 
-    if (thread_create(&main_tcb, main_stack, sizeof(main_stack), PRIORITY_IDLE, CREATE_WOUT_YIELD | CREATE_STACKTEST, idle_stack, idle_name) < 0) {
+    if (thread_create(&main_tcb, main_stack, sizeof(main_stack), PRIORITY_IDLE, CREATE_WOUT_YIELD | CREATE_STACKTEST, idle_thread, idle_name) < 0) {
         printf("kernel_init(): error creating idle task.\n");
     }
 
diff --git a/core/sched.c b/core/sched.c
index 907a635fd9d7dbb5a5565de00e578b9ffab70a31..03e2f4f32a02c28ca7c8ef4537518f041aa2fce6 100644
--- a/core/sched.c
+++ b/core/sched.c
@@ -149,14 +149,12 @@ extern void cpu_switch_context_exit(void);
 void sched_task_exit(void) {
     DEBUG("sched_task_exit(): ending task %s...\n", active_thread->name);
 
-    tcb* thread = (tcb*)active_thread;
     dINT();
     sched_threads[active_thread->pid] = NULL;
     num_tasks--;
     
     sched_set_status((tcb*)active_thread,  STATUS_STOPPED);
 
-    free(((tcb*)active_thread)->stack_start);
     active_thread = NULL;
     cpu_switch_context_exit();
 }
diff --git a/core/thread.c b/core/thread.c
index 49fbc53a5cfe78836147d286972026bda950945e..779fc2b6b5dcf17763937c1867e17f29e3772745 100644
--- a/core/thread.c
+++ b/core/thread.c
@@ -107,7 +107,7 @@ int thread_create(tcb *cb, char *stack, int stacksize, char priority, int flags,
     while (pid < MAXTHREADS) {
         if (sched_threads[pid] == NULL) {
             sched_threads[pid] = cb;
-            pd->pid = pid;
+            cb->pid = pid;
             break;
         }
         pid++;