some memory fixes