Preliminary fix for rank losses. This fix has to be checked again.