move file templates to separate files; simplify flow/improve readability of generate.py