Cleaned up code in tiles.py.