MAINT trim away >10 kLOC of generated C code

Trimmed away some dead code and used lower-level APIs were it didn't hurt readability. This is intended to get smaller code, not extra speed, and the generated C code is <del>hundreds of</del> more than 10.000 lines shorter.
Shouldn't be, but I'm not sure if the tests will catch it. Cython doesn't get boolean arrays. The code previously used the slow workaround of casting each element in turn to `object`, but a bool array is actually an array of bytes.

I guess I can write a test for this if you want.