Swapped the order of the parameters of the calcmean functions: result
comes first now.