Misc files for C and Py3 upgrade.
See 4.12 of https://docs.google.com/spreadsheets/d/1lQJzSIE6iUhlRQ5O4gjHBnIpsqFS7w3DQw3wX5_66P8/edit#gid=1881169084
Changes
This MR includes small remaining changes for C files, and deletes an old redundant cuda patch.
This repeats all changes from !226 (closed) for these files.
Purpose
I intend to split !226 (closed)'s changes into a number of MRs, which won't be functional code versions themselves, but once complete will encompass the full set of changes to upgrade to py3.
This should provide useful code diffs for reviewers.