Generate now works. Beginning of refactor for templates