Restructure and improve data munging