Restructure data in datatools