fixed bugs in code-generation process. added new template. added template doc.