Refactoring: change cheetah to jinja2, clean up functionality