many changes

Whoops, this was supposed to have been tons of separate commits over a
long period of time...  Sorry about that