Template and class fixes from code review.