Reapplied fixes to models.py