More fixes = broken.

This commit is broken due to changes required to make average2 (and other
modes than average/median) function correctly.

A set of tests will be added shortly for each step of the processing code
to check the functionality of functions vs. that in MATLAB + the test
code committed to the repository.