some clean-ups
new memory management