Converted lots of code to CUDA

Still linker errors =(.
Fix linker errors