Fixed issue with weight calculation (#1074)