Another pass of cleanup and generalization.