Fix style and syntax issues, make kernel check a bit more robust.