Further refactoring of the dom