Misc attempts at releasing resources earlier to stop an out of memory issue