fix opt_kernel_path writing over the allocated memory! also some small changes for more robust hard restart