Move adding classes to the templating layer

Fixes #5.