Make it compile on cuda < 6.0 and add fix 0-size cases.