Remove empty elements during conversion