replaces erb with doT.js templates, and makes a few bug fixes