Major cleanup and more optimizations.
Make build independent of CUDA SDK.