Made CUDA compatible with device rewrite