Index: /branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.4/PreprocessingTransformator.cs
===================================================================
--- /branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.4/PreprocessingTransformator.cs	(revision 10975)
+++ /branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.4/PreprocessingTransformator.cs	(revision 10976)
@@ -33,7 +33,10 @@
     private readonly IDictionary<string, IList<double>> originalColumns;
 
+    private readonly IDictionary<string, string> renamedColumns;
+
     public PreprocessingTransformator(IPreprocessingData preprocessingData) {
       this.preprocessingData = (ITransactionalPreprocessingData)preprocessingData;
       originalColumns = new Dictionary<string, IList<double>>();
+      renamedColumns = new Dictionary<string, string>();
     }
 
@@ -42,11 +45,22 @@
 
       preprocessingData.BeginTransaction(DataPreprocessingChangedEventType.Transformation);
+
       try {
         var doubleTransformations = transformations.OfType<Transformation<double>>().ToList();
-        ApplyDoubleTranformations(doubleTransformations, preserveColumns, out success, out errorMsg);
 
         if (preserveColumns) {
-          RestorePreservedColumns(doubleTransformations);
+          PreserveColumns(doubleTransformations);
+        }
+
+        // all transformations are performed inplace. no creation of new columns for transformations
+        ApplyDoubleTranformationsInplace(doubleTransformations, preserveColumns, out success, out errorMsg);
+
+        if (preserveColumns) {
+          RenameTransformedColumsAndRestorePreservedColumns(doubleTransformations);
+          RenameTransformationColumnParameter(doubleTransformations);
+          InsertCopyColumTransformations(doubleTransformations);
+
           originalColumns.Clear();
+          renamedColumns.Clear();
         }
       } finally {
@@ -57,5 +71,15 @@
     }
 
-    private void ApplyDoubleTranformations(IList<Transformation<double>> transformations, bool preserveColumns, out bool success, out string errorMsg) {
+    private void PreserveColumns(IList<Transformation<double>> transformations) {
+      foreach (var transformation in transformations) {
+        if (!originalColumns.ContainsKey(transformation.Column)) {
+          int colIndex = preprocessingData.GetColumnIndex(transformation.Column);
+          var originalData = preprocessingData.GetValues<double>(colIndex);
+          originalColumns.Add(transformation.Column, originalData);
+        }
+      }
+    }
+
+    private void ApplyDoubleTranformationsInplace(IList<Transformation<double>> transformations, bool preserveColumns, out bool success, out string errorMsg) {
       errorMsg = string.Empty;
       success = true;
@@ -64,7 +88,4 @@
 
         var originalData = preprocessingData.GetValues<double>(colIndex);
-
-        if (preserveColumns && !originalColumns.ContainsKey(transformation.Column))
-          originalColumns.Add(transformation.Column, originalData);
 
         string errorMsgPart;
@@ -84,10 +105,47 @@
     }
 
-    private void RestorePreservedColumns(IList<Transformation<double>> transformations) {
+    private void RenameTransformationColumnParameter(List<Transformation<double>> transformations) {
+      foreach (var transformation in transformations) {
+        var newColumnName = new StringValue(renamedColumns[transformation.Column]);
+        transformation.ColumnParameter.ValidValues.Add(newColumnName);
+        transformation.ColumnParameter.Value = newColumnName;
+      }
+    }
+
+    private void InsertCopyColumTransformations(IList<Transformation<double>> transformations) {
+      foreach (var renaming in renamedColumns) {
+        string oldName = renaming.Key;
+        string newName = renaming.Value;
+
+        var copyTransformation = CreateCopyTransformation(oldName, newName);
+        preprocessingData.Transformations.Add(copyTransformation);
+
+      }
+
+      //var transformedColumns = transformations.Select(x => x.Column).Distinct();
+      //foreach (var column in transformedColumns) {
+      //  var copyTransformation = CreateCopyTransformation(column);
+      //  preprocessingData.Transformations.Add(copyTransformation);
+      //}
+    }
+
+    private CopyColumnTransformation CreateCopyTransformation(string oldColumn, string newColumn) {
+      var newColumName = new StringValue(newColumn);
+
+      var copyTransformation = new CopyColumnTransformation();
+      copyTransformation.ColumnParameter.ValidValues.Add(newColumName);
+      copyTransformation.ColumnParameter.Value = newColumName;
+
+      copyTransformation.CopiedColumnNameParameter.Value.Value = oldColumn;
+      return copyTransformation;
+    }
+
+    private void RenameTransformedColumsAndRestorePreservedColumns(IList<Transformation<double>> transformations) {
       foreach (var column in originalColumns) {
         int originalColumnIndex = preprocessingData.GetColumnIndex(column.Key);
         int newColumnIndex = originalColumnIndex + 1;
         string newColumnName = GetTransformatedColumnName(transformations, column.Key);
-
+        // save renaming mapping
+        renamedColumns[column.Key] = newColumnName;
         // create new transformed column
         preprocessingData.InsertColumn<double>(newColumnName, newColumnIndex);
