Refactored loading and saving of data