Update models.py

Ported calculating weights correctly from master. [9991826]