Changed repo to return Template objects.

Improved error messages.