Fix memory management.