Add comments and refactor template files
Add comment and small refactoring to generator