closes issue #15 - fixed some issues in templates.js