Add kernel thread support.
Remove obselete stuff.