Simplify logic of Data methods and fix #8335