Hopefully last batch of memory fixes