Bug fixes in deal.py