Refactored the weighting code.