controller generator refactoring and fixes