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

Yes I know. But that is only upon reuse of the command and all the while in between the memory is claimed and unused. Just doing my part to reduce excess memory footprint.
Rebased.