Added models.py and bug fixes associated with it