PMD.
diff --git a/commons-math-examples/examples-sofm/chinese-rings/src/main/java/org/apache/commons/math4/examples/sofm/chineserings/ChineseRings.java b/commons-math-examples/examples-sofm/chinese-rings/src/main/java/org/apache/commons/math4/examples/sofm/chineserings/ChineseRings.java
index 4289dad..3127c1c 100644
--- a/commons-math-examples/examples-sofm/chinese-rings/src/main/java/org/apache/commons/math4/examples/sofm/chineserings/ChineseRings.java
+++ b/commons-math-examples/examples-sofm/chinese-rings/src/main/java/org/apache/commons/math4/examples/sofm/chineserings/ChineseRings.java
@@ -131,7 +131,7 @@
                 /** Data. */
                 private final Vector3D[] points = getPoints();
                 /** Number of samples. */
-                private int n = 0;
+                private int n;
 
                 /** {@inheritDoc} */
                 @Override
diff --git a/commons-math-examples/examples-sofm/chinese-rings/src/main/java/org/apache/commons/math4/examples/sofm/chineserings/ChineseRingsClassifier.java b/commons-math-examples/examples-sofm/chinese-rings/src/main/java/org/apache/commons/math4/examples/sofm/chineserings/ChineseRingsClassifier.java
index b85c496..d8c5560 100644
--- a/commons-math-examples/examples-sofm/chinese-rings/src/main/java/org/apache/commons/math4/examples/sofm/chineserings/ChineseRingsClassifier.java
+++ b/commons-math-examples/examples-sofm/chinese-rings/src/main/java/org/apache/commons/math4/examples/sofm/chineserings/ChineseRingsClassifier.java
@@ -124,23 +124,23 @@
      * z coordinates of the features array of the neurons.
      */
     private FeatureInitializer[] makeInitializers() {
-        final SummaryStatistics[] centre = new SummaryStatistics[] {
+        final SummaryStatistics[] centre = {
             new SummaryStatistics(),
             new SummaryStatistics(),
             new SummaryStatistics()
         };
-        for (Vector3D p : rings.getPoints()) {
+        for (final Vector3D p : rings.getPoints()) {
             centre[0].addValue(p.getX());
             centre[1].addValue(p.getY());
             centre[2].addValue(p.getZ());
         }
 
-        final double[] mean = new double[] {
+        final double[] mean = {
             centre[0].getMean(),
             centre[1].getMean(),
             centre[2].getMean()
         };
-        final double[] dev = new double[] {
+        final double[] dev = {
             0.1 * centre[0].getStandardDeviation(),
             0.1 * centre[1].getStandardDeviation(),
             0.1 * centre[2].getStandardDeviation()
@@ -168,7 +168,7 @@
             /** RNG. */
             private final UniformRandomProvider rng = RandomSource.create(RandomSource.KISS);
             /** Number of samples. */
-            private long n = 0;
+            private long n;
 
             /** {@inheritDoc} */
             @Override
diff --git a/commons-math-examples/examples-sofm/tsp/src/main/java/org/apache/commons/math4/examples/sofm/tsp/City.java b/commons-math-examples/examples-sofm/tsp/src/main/java/org/apache/commons/math4/examples/sofm/tsp/City.java
index f55c3e4..47ec32d 100644
--- a/commons-math-examples/examples-sofm/tsp/src/main/java/org/apache/commons/math4/examples/sofm/tsp/City.java
+++ b/commons-math-examples/examples-sofm/tsp/src/main/java/org/apache/commons/math4/examples/sofm/tsp/City.java
@@ -87,7 +87,7 @@
                                Set<City> cities) {
         City closest = null;
         double min = Double.POSITIVE_INFINITY;
-        for (City c : cities) {
+        for (final City c : cities) {
             final double d = c.distance(x, y);
             if (d < min) {
                 min = d;
@@ -108,7 +108,7 @@
         double yB = 0;
 
         int count = 0;
-        for (City c : cities) {
+        for (final City c : cities) {
             final double[] coord = c.getCoordinates();
             xB += coord[0];
             yB += coord[1];
@@ -132,7 +132,7 @@
                                          double y,
                                          Set<City> cities) {
         double maxDist = 0;
-        for (City c : cities) {
+        for (final City c : cities) {
             final double dist = c.distance(x, y);
             if (dist > maxDist) {
                 maxDist = dist;
diff --git a/commons-math-examples/examples-sofm/tsp/src/main/java/org/apache/commons/math4/examples/sofm/tsp/StandAlone.java b/commons-math-examples/examples-sofm/tsp/src/main/java/org/apache/commons/math4/examples/sofm/tsp/StandAlone.java
index bbd768b..6dd92fe 100644
--- a/commons-math-examples/examples-sofm/tsp/src/main/java/org/apache/commons/math4/examples/sofm/tsp/StandAlone.java
+++ b/commons-math-examples/examples-sofm/tsp/src/main/java/org/apache/commons/math4/examples/sofm/tsp/StandAlone.java
@@ -55,7 +55,7 @@
     /** The output file. */
     @Option(names = { "-o" }, paramLabel = "outputFile", required = true,
             description = "Output file name.")
-    private String outputFile = null;
+    private String outputFile;
 
     /**
      * Program entry point.
@@ -69,7 +69,7 @@
     @Override
     public Void call() throws FileNotFoundException, UnsupportedEncodingException {
         // Cities (in optimal travel order).
-        final City[] cities = new City[] {
+        final City[] cities = {
             new City("o0", 0, 0),
             new City("o1", 1, 0),
             new City("o2", 2, 0),
@@ -158,8 +158,7 @@
             out.println("# Travel distance: " + computeDistance(travel));
             out.println("# Optimal travel distance: " + optimalDistance);
 
-            for (int i = 0; i < travel.length; i++) {
-                final City c = travel[i];
+            for (final City c : travel) {
                 final double[] coord = c.getCoordinates();
                 out.println(coord[0] + " " + coord[1] + " # " + c.getName());
             }
diff --git a/commons-math-examples/examples-sofm/tsp/src/main/java/org/apache/commons/math4/examples/sofm/tsp/TravellingSalesmanSolver.java b/commons-math-examples/examples-sofm/tsp/src/main/java/org/apache/commons/math4/examples/sofm/tsp/TravellingSalesmanSolver.java
index d6eb45b..0a1b263 100644
--- a/commons-math-examples/examples-sofm/tsp/src/main/java/org/apache/commons/math4/examples/sofm/tsp/TravellingSalesmanSolver.java
+++ b/commons-math-examples/examples-sofm/tsp/src/main/java/org/apache/commons/math4/examples/sofm/tsp/TravellingSalesmanSolver.java
@@ -115,12 +115,12 @@
                                                     numUpdates / numTasks);
         final List<Future<?>> execOutput = new ArrayList<>();
         // Run tasks.
-        for (Runnable r : tasks) {
+        for (final Runnable r : tasks) {
             execOutput.add(service.submit(r));
         }
         // Wait for completion (ignoring return value).
         try {
-            for (Future<?> f : execOutput) {
+            for (final Future<?> f : execOutput) {
                 f.get();
             }
         } catch (InterruptedException | ExecutionException e) {
@@ -189,7 +189,7 @@
 
         return new Iterator<double[]>() {
             /** Number of samples. */
-            private long n = 0;
+            private long n;
             /** {@inheritDoc} */
             @Override
             public boolean hasNext() {
@@ -245,7 +245,7 @@
         // Sequence of coordinates.
         final List<double[]> coordinatesList = new ArrayList<>();
 
-        for (Neuron n : getNeuronList()) {
+        for (final Neuron n : getNeuronList()) {
             coordinatesList.add(n.getFeatures());
         }
 
@@ -262,7 +262,8 @@
         final List<double[]> coord = getCoordinatesList();
         final List<City> cityList = new ArrayList<>();
         City previous = null;
-        for (int i = 0, max = coord.size(); i < max; i++) {
+        final int max = coord.size();
+        for (int i = 0; i < max; i++) {
             final double[] c = coord.get(i);
             final City next = City.closest(c[0], c[1], cities);
             if (!next.equals(previous)) {
diff --git a/commons-math-neuralnet/src/main/java/org/apache/commons/math4/neuralnet/MapRanking.java b/commons-math-neuralnet/src/main/java/org/apache/commons/math4/neuralnet/MapRanking.java
index 903301c..e74c7a7 100644
--- a/commons-math-neuralnet/src/main/java/org/apache/commons/math4/neuralnet/MapRanking.java
+++ b/commons-math-neuralnet/src/main/java/org/apache/commons/math4/neuralnet/MapRanking.java
@@ -46,7 +46,7 @@
                       DistanceMeasure distance) {
         this.distance = distance;
 
-        for (Neuron n : neurons) {
+        for (final Neuron n : neurons) {
             map.add(n); // No defensive copy.
         }
     }
@@ -109,7 +109,7 @@
         }
 
         final List<Neuron> result = new ArrayList<>(m);
-        for (PairNeuronDouble p : list) {
+        for (final PairNeuronDouble p : list) {
             result.add(p.getNeuron());
         }
 
diff --git a/commons-math-neuralnet/src/main/java/org/apache/commons/math4/neuralnet/MapUtils.java b/commons-math-neuralnet/src/main/java/org/apache/commons/math4/neuralnet/MapUtils.java
index ea4f070..2f648a4 100644
--- a/commons-math-neuralnet/src/main/java/org/apache/commons/math4/neuralnet/MapUtils.java
+++ b/commons-math-neuralnet/src/main/java/org/apache/commons/math4/neuralnet/MapUtils.java
@@ -50,7 +50,7 @@
 
         double d = 0;
         int count = 0;
-        for (double[] f : data) {
+        for (final double[] f : data) {
             ++count;
             d += distance.applyAsDouble(f, rank.rank(f, 1).get(0).getFeatures());
         }
@@ -80,7 +80,7 @@
 
         int notAdjacentCount = 0;
         int count = 0;
-        for (double[] f : data) {
+        for (final double[] f : data) {
             ++count;
             final List<Neuron> p = rank.rank(f, 2);
             if (!net.getNeighbours(p.get(0)).contains(p.get(1))) {
diff --git a/commons-math-neuralnet/src/main/java/org/apache/commons/math4/neuralnet/Network.java b/commons-math-neuralnet/src/main/java/org/apache/commons/math4/neuralnet/Network.java
index 7de495a..19101a4 100644
--- a/commons-math-neuralnet/src/main/java/org/apache/commons/math4/neuralnet/Network.java
+++ b/commons-math-neuralnet/src/main/java/org/apache/commons/math4/neuralnet/Network.java
@@ -114,7 +114,7 @@
         for (int i = 0; i < numNeurons; i++) {
             final long aId = neuronList[i].getIdentifier();
             final Set<Long> aLinks = linkMap.get(aId);
-            for (Long bId : neighbourIdList[i]) {
+            for (final Long bId : neighbourIdList[i]) {
                 if (neuronMap.get(bId) == null) {
                     throw new IllegalStateException();
                 }
@@ -150,11 +150,11 @@
                                          featureSize);
 
 
-        for (Map.Entry<Long, Neuron> e : neuronMap.entrySet()) {
+        for (final Map.Entry<Long, Neuron> e : neuronMap.entrySet()) {
             copy.neuronMap.put(e.getKey(), e.getValue().copy());
         }
 
-        for (Map.Entry<Long, Set<Long>> e : linkMap.entrySet()) {
+        for (final Map.Entry<Long, Set<Long>> e : linkMap.entrySet()) {
             copy.linkMap.put(e.getKey(), new HashSet<>(e.getValue()));
         }
 
@@ -245,13 +245,12 @@
      */
     public void addLink(Neuron a,
                         Neuron b) {
-        final long aId = a.getIdentifier();
-        final long bId = b.getIdentifier();
-
         // Check that the neurons belong to this network.
+        final long aId = a.getIdentifier();
         if (a != getNeuron(aId)) {
             throw new NoSuchElementException(Long.toString(aId));
         }
+        final long bId = b.getIdentifier();
         if (b != getNeuron(bId)) {
             throw new NoSuchElementException(Long.toString(bId));
         }
@@ -283,13 +282,12 @@
      */
     public void deleteLink(Neuron a,
                            Neuron b) {
-        final long aId = a.getIdentifier();
-        final long bId = b.getIdentifier();
-
         // Check that the neurons belong to this network.
+        final long aId = a.getIdentifier();
         if (a != getNeuron(aId)) {
             throw new NoSuchElementException(Long.toString(aId));
         }
+        final long bId = b.getIdentifier();
         if (b != getNeuron(bId)) {
             throw new NoSuchElementException(Long.toString(bId));
         }
@@ -385,13 +383,13 @@
                                             Iterable<Neuron> exclude) {
         final Set<Long> idList = linkMap.get(neuron.getIdentifier());
         if (exclude != null) {
-            for (Neuron n : exclude) {
+            for (final Neuron n : exclude) {
                 idList.remove(n.getIdentifier());
             }
         }
 
         final List<Neuron> neuronList = new ArrayList<>();
-        for (Long id : idList) {
+        for (final Long id : idList) {
             neuronList.add(getNeuron(id));
         }
 
@@ -429,7 +427,7 @@
             final Collection<Neuron> neighbours = getNeighbours(neuronList[i]);
             final long[] neighboursId = new long[neighbours.size()];
             int count = 0;
-            for (Neuron n : neighbours) {
+            for (final Neuron n : neighbours) {
                 neighboursId[count] = n.getIdentifier();
                 ++count;
             }
diff --git a/commons-math-neuralnet/src/main/java/org/apache/commons/math4/neuralnet/oned/NeuronString.java b/commons-math-neuralnet/src/main/java/org/apache/commons/math4/neuralnet/oned/NeuronString.java
index 8ab80c2..c1cec55 100644
--- a/commons-math-neuralnet/src/main/java/org/apache/commons/math4/neuralnet/oned/NeuronString.java
+++ b/commons-math-neuralnet/src/main/java/org/apache/commons/math4/neuralnet/oned/NeuronString.java
@@ -33,6 +33,8 @@
 public class NeuronString implements Serializable {
     /** Serial version ID. */
     private static final long serialVersionUID = 1L;
+    /** Minimal number of neurons. */
+    private static final int MIN_NEURONS = 2;
     /** Underlying network. */
     private final Network network;
     /** Number of neurons. */
@@ -59,8 +61,8 @@
                  double[][] featuresList) {
         size = featuresList.length;
 
-        if (size < 2) {
-            throw new NeuralNetException(NeuralNetException.TOO_SMALL, size, 2);
+        if (size < MIN_NEURONS) {
+            throw new NeuralNetException(NeuralNetException.TOO_SMALL, size, MIN_NEURONS);
         }
 
         this.wrap = wrap;
@@ -100,8 +102,8 @@
     public NeuronString(int num,
                         boolean wrap,
                         FeatureInitializer[] featureInit) {
-        if (num < 2) {
-            throw new NeuralNetException(NeuralNetException.TOO_SMALL, num, 2);
+        if (num < MIN_NEURONS) {
+            throw new NeuralNetException(NeuralNetException.TOO_SMALL, num, MIN_NEURONS);
         }
 
         size = num;
diff --git a/commons-math-neuralnet/src/main/java/org/apache/commons/math4/neuralnet/sofm/KohonenUpdateAction.java b/commons-math-neuralnet/src/main/java/org/apache/commons/math4/neuralnet/sofm/KohonenUpdateAction.java
index 1220905..98ab2dc 100644
--- a/commons-math-neuralnet/src/main/java/org/apache/commons/math4/neuralnet/sofm/KohonenUpdateAction.java
+++ b/commons-math-neuralnet/src/main/java/org/apache/commons/math4/neuralnet/sofm/KohonenUpdateAction.java
@@ -120,7 +120,7 @@
                 neighbours = net.getNeighbours(neighbours, exclude);
 
                 // Update all the neighbours.
-                for (Neuron n : neighbours) {
+                for (final Neuron n : neighbours) {
                     updateNeighbouringNeuron(n, features, neighbourhoodDecay.applyAsDouble(radius));
                 }
 
diff --git a/commons-math-neuralnet/src/main/java/org/apache/commons/math4/neuralnet/twod/NeuronSquareMesh2D.java b/commons-math-neuralnet/src/main/java/org/apache/commons/math4/neuralnet/twod/NeuronSquareMesh2D.java
index f3e5043..ce666c1 100644
--- a/commons-math-neuralnet/src/main/java/org/apache/commons/math4/neuralnet/twod/NeuronSquareMesh2D.java
+++ b/commons-math-neuralnet/src/main/java/org/apache/commons/math4/neuralnet/twod/NeuronSquareMesh2D.java
@@ -50,6 +50,8 @@
                Serializable {
     /** Serial version ID. */
     private static final long serialVersionUID = 1L;
+    /** Minimal number of rows or columns. */
+    private static final int MIN_ROWS = 2;
     /** Underlying network. */
     private final Network network;
     /** Number of rows. */
@@ -114,11 +116,11 @@
         numberOfRows = featuresList.length;
         numberOfColumns = featuresList[0].length;
 
-        if (numberOfRows < 2) {
-            throw new NeuralNetException(NeuralNetException.TOO_SMALL, numberOfRows, 2);
+        if (numberOfRows < MIN_ROWS) {
+            throw new NeuralNetException(NeuralNetException.TOO_SMALL, numberOfRows, MIN_ROWS);
         }
-        if (numberOfColumns < 2) {
-            throw new NeuralNetException(NeuralNetException.TOO_SMALL, numberOfColumns, 2);
+        if (numberOfColumns < MIN_ROWS) {
+            throw new NeuralNetException(NeuralNetException.TOO_SMALL, numberOfColumns, MIN_ROWS);
         }
 
         wrapRows = wrapRowDim;
@@ -171,11 +173,11 @@
                               boolean wrapColDim,
                               SquareNeighbourhood neighbourhoodType,
                               FeatureInitializer[] featureInit) {
-        if (numRows < 2) {
-            throw new NeuralNetException(NeuralNetException.TOO_SMALL, numRows, 2);
+        if (numRows < MIN_ROWS) {
+            throw new NeuralNetException(NeuralNetException.TOO_SMALL, numRows, MIN_ROWS);
         }
-        if (numCols < 2) {
-            throw new NeuralNetException(NeuralNetException.TOO_SMALL, numCols, 2);
+        if (numCols < MIN_ROWS) {
+            throw new NeuralNetException(NeuralNetException.TOO_SMALL, numCols, MIN_ROWS);
         }
 
         numberOfRows = numRows;
@@ -559,7 +561,7 @@
                 }
 
                 final Neuron aNeuron = network.getNeuron(identifiers[i][j]);
-                for (long b : linkEnd) {
+                for (final long b : linkEnd) {
                     final Neuron bNeuron = network.getNeuron(b);
                     // Link to all neighbours.
                     // The reverse links will be added as the loop proceeds.
@@ -715,7 +717,7 @@
             final double[][] uMatrix = new double[nR][nC];
 
             int numSamples = 0;
-            for (double[] sample : data) {
+            for (final double[] sample : data) {
                 ++numSamples;
 
                 final List<Neuron> winners = rank.rank(sample, 2);
@@ -746,7 +748,7 @@
                     final double[] features = neuron.getFeatures();
                     double uDistance = 0;
                     int neighbourCount = 0;
-                    for (Neuron n : neighbours) {
+                    for (final Neuron n : neighbours) {
                         ++neighbourCount;
                         uDistance += DISTANCE.applyAsDouble(features, n.getFeatures());
                     }
diff --git a/commons-math-neuralnet/src/main/java/org/apache/commons/math4/neuralnet/twod/util/LocationFinder.java b/commons-math-neuralnet/src/main/java/org/apache/commons/math4/neuralnet/twod/util/LocationFinder.java
index 7ba8d2d..ffc7c38 100644
--- a/commons-math-neuralnet/src/main/java/org/apache/commons/math4/neuralnet/twod/util/LocationFinder.java
+++ b/commons-math-neuralnet/src/main/java/org/apache/commons/math4/neuralnet/twod/util/LocationFinder.java
@@ -18,7 +18,7 @@
 package org.apache.commons.math4.neuralnet.twod.util;
 
 import java.util.Map;
-import java.util.HashMap;
+import java.util.concurrent.ConcurrentHashMap;
 import org.apache.commons.math4.neuralnet.Neuron;
 import org.apache.commons.math4.neuralnet.twod.NeuronSquareMesh2D;
 
@@ -28,7 +28,7 @@
  */
 public class LocationFinder {
     /** Identifier to location mapping. */
-    private final Map<Long, Location> locations = new HashMap<>();
+    private final Map<Long, Location> locations = new ConcurrentHashMap<>();
 
     /**
      * Container holding a (row, column) pair.
diff --git a/commons-math-neuralnet/src/main/java/org/apache/commons/math4/neuralnet/twod/util/SmoothedDataHistogram.java b/commons-math-neuralnet/src/main/java/org/apache/commons/math4/neuralnet/twod/util/SmoothedDataHistogram.java
index b59d924..d042dad 100644
--- a/commons-math-neuralnet/src/main/java/org/apache/commons/math4/neuralnet/twod/util/SmoothedDataHistogram.java
+++ b/commons-math-neuralnet/src/main/java/org/apache/commons/math4/neuralnet/twod/util/SmoothedDataHistogram.java
@@ -84,7 +84,7 @@
         // Histogram bins.
         final double[][] histo = new double[nR][nC];
 
-        for (double[] sample : data) {
+        for (final double[] sample : data) {
             final List<Neuron> sorted = rank.rank(sample);
             for (int i = 0; i < smoothingBins; i++) {
                 final LocationFinder.Location loc = finder.getLocation(sorted.get(i));
diff --git a/commons-math-transform/src/main/java/org/apache/commons/math4/transform/FastCosineTransform.java b/commons-math-transform/src/main/java/org/apache/commons/math4/transform/FastCosineTransform.java
index 6de9ffc..fcd4092 100644
--- a/commons-math-transform/src/main/java/org/apache/commons/math4/transform/FastCosineTransform.java
+++ b/commons-math-transform/src/main/java/org/apache/commons/math4/transform/FastCosineTransform.java
@@ -113,13 +113,14 @@
      * not a power of two plus one.
      */
     private double[] fct(double[] f) {
-        final double[] transformed = new double[f.length];
-
         final int n = f.length - 1;
         if (!ArithmeticUtils.isPowerOfTwo(n)) {
             throw new TransformException(TransformException.NOT_POWER_OF_TWO_PLUS_ONE,
                                          Integer.valueOf(f.length));
         }
+
+        final double[] transformed = new double[f.length];
+
         if (n == 1) {       // trivial case
             transformed[0] = 0.5 * (f[0] + f[1]);
             transformed[1] = 0.5 * (f[0] - f[1]);
diff --git a/commons-math-transform/src/main/java/org/apache/commons/math4/transform/FastFourierTransform.java b/commons-math-transform/src/main/java/org/apache/commons/math4/transform/FastFourierTransform.java
index 182b1c1..a0a357d 100644
--- a/commons-math-transform/src/main/java/org/apache/commons/math4/transform/FastFourierTransform.java
+++ b/commons-math-transform/src/main/java/org/apache/commons/math4/transform/FastFourierTransform.java
@@ -40,6 +40,8 @@
  * Computation, 32 (1978), 175 - 199.
  */
 public class FastFourierTransform implements ComplexTransform {
+    /** Number of array slots: 1 for "real" parts 1 for "imaginary" parts. */
+    private static final int NUM_PARTS = 2;
     /**
      * {@code W_SUB_N_R[i]} is the real part of
      * {@code exp(- 2 * i * pi / n)}:
@@ -125,9 +127,9 @@
      * or the array is not rectangular.
      */
     public void transformInPlace(final double[][] dataRI) {
-        if (dataRI.length != 2) {
+        if (dataRI.length != NUM_PARTS) {
             throw new TransformException(TransformException.SIZE_MISMATCH,
-                                         dataRI.length, 2);
+                                         dataRI.length, NUM_PARTS);
         }
         final double[] dataR = dataRI[0];
         final double[] dataI = dataRI[1];
@@ -228,7 +230,7 @@
         while (lastN0 < n) {
             final int n0 = lastN0 << 1;
             final int logN0 = lastLogN0 + 1;
-            double wSubN0R = W_SUB_N_R[logN0];
+            final double wSubN0R = W_SUB_N_R[logN0];
             double wSubN0I = W_SUB_N_I[logN0];
             if (inverse) {
                 wSubN0I = -wSubN0I;
@@ -281,7 +283,7 @@
      */
     @Override
     public Complex[] apply(final double[] f) {
-        final double[][] dataRI = new double[][] {
+        final double[][] dataRI = {
             Arrays.copyOf(f, f.length),
             new double[f.length]
         };
diff --git a/commons-math-transform/src/main/java/org/apache/commons/math4/transform/FastHadamardTransform.java b/commons-math-transform/src/main/java/org/apache/commons/math4/transform/FastHadamardTransform.java
index b187815..c670211 100644
--- a/commons-math-transform/src/main/java/org/apache/commons/math4/transform/FastHadamardTransform.java
+++ b/commons-math-transform/src/main/java/org/apache/commons/math4/transform/FastHadamardTransform.java
@@ -216,13 +216,14 @@
      */
     private double[] fht(double[] x) {
         final int n = x.length;
-        final int halfN = n / 2;
 
         if (!ArithmeticUtils.isPowerOfTwo(n)) {
             throw new TransformException(TransformException.NOT_POWER_OF_TWO,
                                          n);
         }
 
+        final int halfN = n / 2;
+
         // Instead of creating a matrix with p+1 columns and n rows, we use two
         // one dimension arrays which we are used in an alternating way.
         double[] yPrevious = new double[n];
@@ -263,13 +264,13 @@
      */
     private int[] fht(int[] x) {
         final int n = x.length;
-        final int halfN = n / 2;
-
         if (!ArithmeticUtils.isPowerOfTwo(n)) {
             throw new TransformException(TransformException.NOT_POWER_OF_TWO,
                                          n);
         }
 
+        final int halfN = n / 2;
+
         // Instead of creating a matrix with p+1 columns and n rows, we use two
         // one dimension arrays which we are used in an alternating way.
 
diff --git a/commons-math-transform/src/main/java/org/apache/commons/math4/transform/RealTransform.java b/commons-math-transform/src/main/java/org/apache/commons/math4/transform/RealTransform.java
index 8f8f6af..3151d11 100644
--- a/commons-math-transform/src/main/java/org/apache/commons/math4/transform/RealTransform.java
+++ b/commons-math-transform/src/main/java/org/apache/commons/math4/transform/RealTransform.java
@@ -30,6 +30,7 @@
      * @return the transformed array (spectrum).
      * @throws IllegalArgumentException if the transform cannot be performed.
      */
+    @Override
     double[] apply(double[] f);
 
     /**
diff --git a/commons-math-transform/src/main/java/org/apache/commons/math4/transform/TransformUtils.java b/commons-math-transform/src/main/java/org/apache/commons/math4/transform/TransformUtils.java
index c2168c8..9a54af9 100644
--- a/commons-math-transform/src/main/java/org/apache/commons/math4/transform/TransformUtils.java
+++ b/commons-math-transform/src/main/java/org/apache/commons/math4/transform/TransformUtils.java
@@ -25,6 +25,9 @@
  * Class is package-private (for internal use only).
  */
 final class TransformUtils {
+    /** Number of array slots: 1 for "real" parts 1 for "imaginary" parts. */
+    private static final int NUM_PARTS = 2;
+
     /** Utility class. */
     private TransformUtils() {}
 
@@ -99,9 +102,9 @@
      * array is not two, or the array is not rectangular.
      */
     static Complex[] createComplex(final double[][] dataRI) {
-        if (dataRI.length != 2) {
+        if (dataRI.length != NUM_PARTS) {
             throw new TransformException(TransformException.SIZE_MISMATCH,
-                                         dataRI.length, 2);
+                                         dataRI.length, NUM_PARTS);
         }
         final double[] dataR = dataRI[0];
         final double[] dataI = dataRI[1];