Some CUDA backend refactoring, typo fix in yacc.py

Sorry for the huge number of whitespace strips, my editor does that automatically so hopefully they don't mask any of the actual changes.  All the tests still pass, so I don't believe the changes should cause any regressions.

I think as we undertake this backend migration we should fill out our test suite to prevent against regressions.