Fix bug when both duplicated tiles and extra tiles exist.