Lots of dangerous changes to be tested
    * changed a lot of pass-by-copy to pointers
    * changes max_variance to take only 2 params