small fix to generator
improved generate and templates and move some things around