CUDA fixes, in hope it will work on both OSX and Linux now.