Fixed mixup between empty() and clear() so memory is realesed correctly

I see.