Got rid of a ton of unused variables

There might even be some performance speedups! Maybe! Probably not.

Mostly gets rid of flake8's F841 errors, but there's a few bits of
awkward code that'll require a small refactor to fix.