changed structure to use jinja2 for templating, autoescaping, and other good stuff