Improved codegenerator