Fix loop boundaries in save and load operations