Made LuaJ kernel error checking more robust.