Refactor the stub generator.