memory fixes from Hannah
memory fixes from Hannah

shevek/libspf2,shevek/libspf2,rubicks/libspf2,shevek/libspf2,rubicks/libspf2,shevek/libspf2,rubicks/libspf2,shevek/libspf2,rubicks/libspf2,rubicks/libspf2