Tiling script: fix typo bugs and make error message more detailed