Properly implemented save and load functionality