small memory fixes