Adds jinja2 to requirements.txt
Various refactorings