cleanup && memory fixes