Added debug messages, fixed so the templates work

Only the features used in the templates have been tested and seem to
work just fine