Fixed most of bugs in tile.py