switch to kernel mode and fix some bugs