Revert code optimization which was leading to incorrect results.

Merged Romulo Pereira Goncalves requested to merge carsten_optimization into master

Merge request reports