Fix leaks in data save and load