added general purpose tile size determination code