Refactor tilemap