Reorganized some code in HTMLElements parser