Lots of changes. Fixed sloped tile.

Rearranged a lot of code.