Fix threading errors in Element.