Refactored generating of code.