Refactored templates into classes. Can extract more.