Some memory management fixes, still incomplete