adds some math suff, some comments, beginning of templates and producer