fixes + moved template generation