Fixed some issues with generation of tiles