Fixed tile code to make it compatible with external loading.