I've decided to redo the Tiling functions, as the previous ones were ridiculously confusing. Time to start from scratch