Clean up.
Incorporate most remaining stuff from #117.