Fixed generation of index.tpl content from DB