More cleanup and minor speedup.