Fix for emptying container after elements have been added.
Updated version