Improved tile handling. Bugfixes