Fixed bugs with weights