Crash fixes

Fix several kernel crashes and panics.