Lots of misc cleanup. It's almost functionally equivalent to the older version, now.