Fixes for compiling with CUDA 6.5

Based on commit feb74b125d7923c0bc11054b66863e1e9f753141 from 2.4.9 branch.