fixed bug in kernel_avx and added error reporting