Fix to calculate error in case of not weighted caclulation + some cosmetics