got gen working
reorganized code
minor changes