changed how docTemplates are handled

also lots of cosmetic changes