Improve Racket code

Roughly same speed, but much better looking code.  A bunch of smaller commits with explanations.