Add more logging to the kernel module.

Also some checks so we don't deinitialize uninitialized data.