Integrate xTile.
small modifications