Porting to Python 3, change 'has_key' for 'in'

Porting to Python 3, change 'has_key' for 'in' and minor changes in spaces (PEP8).