Fix to empty element removal routine