Fix up a few minor performance problems spotted in code review.