Broke it trying to make it shorter, the tile creation process

But it is worth making it smaller as the code has started to become
unmanageable now.