more writer refactoring for code generation.