Pie and stack now also support new data format. Also did some refactoring of code