changed T.$tile_ to T.tiles and fixed some bugs