Fixed CUDA bugs