improved KernelArgument casting logic