assorted memory fixes