imported tile rendering stuff from old repo