Fixed problem with tile positions, small recatoring of code