fix for segmentation fault when saving scratchpad