Index: /branches/TSNE/HeuristicLab.Algorithms.DataAnalysis/3.4/TSNE/SPtree.cs
===================================================================
--- /branches/TSNE/HeuristicLab.Algorithms.DataAnalysis/3.4/TSNE/SPtree.cs	(revision 14741)
+++ /branches/TSNE/HeuristicLab.Algorithms.DataAnalysis/3.4/TSNE/SPtree.cs	(revision 14742)
@@ -157,5 +157,5 @@
       // Ignore objects which do not belong in this quad tree
       var point = new double[dimension];
-      Buffer.BlockCopy(Data, (int)(sizeof(double) * dimension * newIndex), point, 0, (int)(sizeof(double) * dimension));
+      Buffer.BlockCopy(Data, sizeof(double) * dimension * newIndex, point, 0, sizeof(double) * dimension);
       if (!boundary.ContainsPoint(point)) return false;
       cumulativeSize++;
@@ -227,6 +227,5 @@
     public bool IsCorrect() {
       var row = new double[dimension];
-      for (var n = 0; n < size; n++)
-        Buffer.BlockCopy(Data, (int)(sizeof(double) * dimension * n), row, 0, (int)(sizeof(double) * dimension));
+      for (var n = 0; n < size; n++) Buffer.BlockCopy(Data, sizeof(double) * dimension * n, row, 0, sizeof(double) * dimension);
       if (!boundary.ContainsPoint(row)) return false;
       if (isLeaf) return true;
Index: /branches/TSNE/HeuristicLab.Algorithms.DataAnalysis/3.4/TSNE/TSNE.cs
===================================================================
--- /branches/TSNE/HeuristicLab.Algorithms.DataAnalysis/3.4/TSNE/TSNE.cs	(revision 14741)
+++ /branches/TSNE/HeuristicLab.Algorithms.DataAnalysis/3.4/TSNE/TSNE.cs	(revision 14742)
@@ -132,6 +132,5 @@
       this.results = results;
       this.dataRowLookup = dataRowLookup;
-      if (dataRows != null)
-        this.dataRows = dataRows;
+      if (dataRows != null) this.dataRows = dataRows;
       else { this.dataRows = new Dictionary<string, ScatterPlotDataRow>(); }
     }
@@ -200,9 +199,7 @@
 
     private void SetUpResults(IReadOnlyCollection<T> data) {
-      if (dataRowLookup == null) {
-        dataRowLookup = new Dictionary<string, List<int>>();
-        dataRowLookup.Add("Data", Enumerable.Range(0, data.Count).ToList());
-      }
+      if (dataRowLookup == null) dataRowLookup = new Dictionary<string, List<int>> { { "Data", Enumerable.Range(0, data.Count).ToList() } };
       if (results == null) return;
+
       if (!results.ContainsKey(IterationResultName)) results.Add(new Result(IterationResultName, new IntValue(0)));
       else ((IntValue)results[IterationResultName].Value).Value = 0;
@@ -216,8 +213,8 @@
       var plot = results[ErrorPlotResultName].Value as DataTable;
       if (plot == null) throw new ArgumentException("could not create/access Error-DataTable in Results-Collection");
-      if (!plot.Rows.ContainsKey("errors")) {
-        plot.Rows.Add(new DataRow("errors"));
-      }
+
+      if (!plot.Rows.ContainsKey("errors")) plot.Rows.Add(new DataRow("errors"));
       plot.Rows["errors"].Values.Clear();
+
       results.Add(new Result(ScatterPlotResultName, "Plot of the projected data", new ScatterPlot(DataResultName, "")));
       results.Add(new Result(DataResultName, "Projected Data", new DoubleMatrix()));
@@ -245,10 +242,7 @@
     private void FillScatterPlot(double[,] lowDimData, ScatterPlot plot) {
       foreach (var rowName in dataRowLookup.Keys) {
-        if (!plot.Rows.ContainsKey(rowName)) {
+        if (!plot.Rows.ContainsKey(rowName))
           plot.Rows.Add(dataRows.ContainsKey(rowName) ? dataRows[rowName] : new ScatterPlotDataRow(rowName, "", new List<Point2D<double>>()));
-        }
-        //else plot.Rows[rowName].Points.Clear();
         plot.Rows[rowName].Points.Replace(dataRowLookup[rowName].Select(i => new Point2D<double>(lowDimData[i, 0], lowDimData[i, 1])));
-        //plot.Rows[rowName].Points.AddRange();
       }
     }
@@ -503,5 +497,5 @@
       tree.ComputeEdgeForces(rowP, colP, valP, n, posF);
       var row = new double[d];
-      for (int n1 = 0; n1 < n; n1++) {
+      for (var n1 = 0; n1 < n; n1++) {
         Buffer.BlockCopy(negF, (sizeof(double) * n1 * d), row, 0, d);
         tree.ComputeNonEdgeForces(n1, theta, row, sumQ);
Index: /branches/TSNE/HeuristicLab.Algorithms.DataAnalysis/3.4/TSNE/TSNEAnalysis.cs
===================================================================
--- /branches/TSNE/HeuristicLab.Algorithms.DataAnalysis/3.4/TSNE/TSNEAnalysis.cs	(revision 14741)
+++ /branches/TSNE/HeuristicLab.Algorithms.DataAnalysis/3.4/TSNE/TSNEAnalysis.cs	(revision 14742)
@@ -57,8 +57,4 @@
       set { base.Problem = value; }
     }
-    #region Resultnames
-    private const string ScatterPlotResultName = "Scatterplot";
-    private const string DataResultName = "Projected Data";
-    #endregion
 
     #region Parameternames
@@ -238,18 +234,15 @@
 
     protected override void Run(CancellationToken cancellationToken) {
-      var data = CalculateProjectedData(Problem.ProblemData);
-      var lowDimData = new DoubleMatrix(data);
-    }
-
-    private double[,] CalculateProjectedData(IDataAnalysisProblemData problemData) {
       var dataRowNames = new Dictionary<string, List<int>>();
       var rows = new Dictionary<string, ScatterPlotDataRow>();
-
+      var problemData = Problem.ProblemData;
+
+      //color datapoints acording to Classes-Variable (be it double or string)
       if (problemData.Dataset.VariableNames.Contains(Classes)) {
         if ((problemData.Dataset as Dataset).VariableHasType<string>(Classes)) {
           var classes = problemData.Dataset.GetStringValues(Classes).ToArray();
-          for (int i = 0; i < classes.Length; i++) {
+          for (var i = 0; i < classes.Length; i++) {
             if (!dataRowNames.ContainsKey(classes[i])) dataRowNames.Add(classes[i], new List<int>());
-            dataRowNames[classes[i]].Add(i); //always succeeds
+            dataRowNames[classes[i]].Add(i);
           }
         } else if ((problemData.Dataset as Dataset).VariableHasType<double>(Classes)) {
@@ -257,18 +250,16 @@
           var max = classValues.Max() + 0.1;
           var min = classValues.Min() - 0.1;
-          var contours = 8;
+          const int contours = 8;
           for (var i = 0; i < contours; i++) {
-            var name = GetContourName(i, min, max, contours);
-            dataRowNames.Add(name, new List<int>());
-            rows.Add(name, new ScatterPlotDataRow(name, "", new List<Point2D<double>>()));
-            rows[name].VisualProperties.Color = GetHeatMapColor(i, contours);
-            rows[name].VisualProperties.PointSize = i + 3;
+            var contourname = GetContourName(i, min, max, contours);
+            dataRowNames.Add(contourname, new List<int>());
+            rows.Add(contourname, new ScatterPlotDataRow(contourname, "", new List<Point2D<double>>()));
+            rows[contourname].VisualProperties.Color = GetHeatMapColor(i, contours);
+            rows[contourname].VisualProperties.PointSize = i + 3;
           }
-          for (int i = 0; i < classValues.Length; i++) {
-            dataRowNames[GetContourName(classValues[i], min, max, contours)].Add(i); //always succeeds
+          for (var i = 0; i < classValues.Length; i++) {
+            dataRowNames[GetContourName(classValues[i], min, max, contours)].Add(i);
           }
-
         }
-
       } else {
         dataRowNames.Add("Training", problemData.TrainingIndices.ToList());
@@ -276,5 +267,7 @@
       }
 
-      var random = SetSeedRandomly ? new MersenneTwister() : new MersenneTwister(Seed);
+      //Set up and run TSNE
+      if (SetSeedRandomly) SeedParameter.Value.Value = new System.Random().Next();
+      var random = new MersenneTwister(Seed);
       tsne = new TSNE<RealVector>(Distance, random, Results, MaxIterations, StopLyingIteration, MomentumSwitchIteration, InitialMomentum, FinalMomentum, Eta, dataRowNames, rows);
       var dataset = problemData.Dataset;
@@ -282,33 +275,24 @@
       var data = new RealVector[dataset.Rows];
       for (var row = 0; row < dataset.Rows; row++) data[row] = new RealVector(allowedInputVariables.Select(col => dataset.GetDoubleValue(col, row)).ToArray());
-
-      if (Normalization) {
-        data = NormalizeData(data);
-      }
-
-      return tsne.Run(data, NewDimensions, Perplexity, Theta);
-    }
-
-    private RealVector[] NormalizeData(RealVector[] data) {
+      if (Normalization) data = NormalizeData(data);
+      tsne.Run(data, NewDimensions, Perplexity, Theta);
+    }
+
+    private static RealVector[] NormalizeData(IReadOnlyList<RealVector> data) {
       var n = data[0].Length;
       var mean = new double[n];
       var sd = new double[n];
-      var nData = new RealVector[data.Length];
+      var nData = new RealVector[data.Count];
       for (var i = 0; i < n; i++) {
         var i1 = i;
-        sd[i] = Enumerable.Range(0, data.Length).Select(x => data[x][i1]).StandardDeviation();
-        mean[i] = Enumerable.Range(0, data.Length).Select(x => data[x][i1]).Average();
+        sd[i] = Enumerable.Range(0, data.Count).Select(x => data[x][i1]).StandardDeviation();
+        mean[i] = Enumerable.Range(0, data.Count).Select(x => data[x][i1]).Average();
       }
-      for (int i = 0; i < data.Length; i++) {
+      for (var i = 0; i < data.Count; i++) {
         nData[i] = new RealVector(n);
-        for (int j = 0; j < n; j++) {
-          nData[i][j] = (data[i][j] - mean[j]) / sd[j];
-        }
+        for (var j = 0; j < n; j++) nData[i][j] = (data[i][j] - mean[j]) / sd[j];
       }
       return nData;
-
-
-    }
-
+    }
     private static Color GetHeatMapColor(int contourNr, int noContours) {
       var q = (double)contourNr / noContours;  // q in [0,1]
