Fix a few things with cuda device