Fixed errors in to_host, to_cuda_host, and to_cuda_device