Extracted auto code generation logic into its own class.