fix some bugs to let ElementPurifier work.