Refactor tile map.
refactor tile map code.