fixes computations for rectangular matrices
NOTE: multi-threaded version is still not secure (non well-defined behaviour)