user/internal code generation refactoring