Fix idle thread bug. Implement syscalls.