Refactoring of models.py