Refactored Tile code

Somehow managed to write all this code without testing, and it doesnt
look like anything broke, so I'm counting that as a small win