optional template blocks implemented. doc.logpop hack added.