simplifications and fixes

I was going through the code to understand it better, and I rewrote some of it. I may have got a little carried away with the last 2 commits, but 17318f9 does fix an actual bug: the code was assuming `cl` was loaded without a require.