Minor bugfixes on kernel