The bug in wait wasn't a bug in wait at all. But I got some things fixed with idle in the meantime...
Commenting and cleaning of memory managers.
More commenting and cleaning.
Now the kernel is running on newlib too. Even malloc and stuff. Awesome!
Completely removed old kernel heap manager.
Enabling interrupts in kernel mode brings Heissenbugs.
Probaby related to the scheduler...
Sever cleanup in system call interface. All system calls but env are now handled in the kernel.