Make generated code shorter by removing duplication